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 (public). By default, these keys are created in the ~/.ssh directory. The next step is to copy 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