Public Key Authentication
Generate ssh-key
ssh-keygen -f ~/.ssh/rsa
Copy new public key to remote hosts ~.ssh/authorized_keys file
ssh-copy-id -i ~/.ssh/rsa.pub user@host
Update configuration
sudo sed -i 's/^#PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
sudo sed -i 's/^#AuthorizedKeysFile\s.ssh\/authorized_keys/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
Or
sudo vi /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
Reload service
sudo systemctl reload ssh # sshd
Connect with ssh
ssh <user>@<host>