OpenSSH key pair authentication

To increase security, let's make a few modifications to /etc/ssh/sshd_config on the server side.

Port 1234

PermitRootLogin no

AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication no

On the client side, generate a key pair using:

ssh-keygen -t rsa

This creates the keys id_rsa (private) and id_rsa.pub (public). By default, these keys are created in the ~/.ssh directory. The next step is to copy id_rsa.pub to the server and append it to ~/.ssh/authorized_keys.


The ssh connection can now be created by executing the command:

ssh -v -p 1234 -i ~/.ssh/id_rsa user@host