SSH Server documentation
How to setup SSH server on Ubuntu
Check SSH service
sudo systemctl status ssh
Install SSH
sudo apt-get update sudo apt-get install openssh-server -y
Enable SSH
sudo systemctl enable ssh
Check or enable firewall
sudo ufw status sudo ufw enable
Add SSH to ufw firewall & reload
sudo ufw allow ssh sudo ufw reload
Add public key to authorized ssh keys
nano ./.ssh/authorized_keys - Paste public key, ctrl + x, ctrl + y & enter
Add directory & file permission
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
Edit the ssh configuration file
sudo nano /etc/ssh/sshd_config
Add the following lines: - ListenAddress 0.0.0.0 - AuthorizedKeysFile .ssh/authorized_keys - PubkeyAuthentication yes - PasswordAuthentication no