Secure Passwordless SSH using Keys

A quick post on how to setup passwordless ssh access between linux hosts.

When generating a key pair, it provides you with a public and a private key. You can place the public key on any server, and then it can be unlocked by connecting to it with a client that already has the private key.

When the validation succeed, the authentication gets verified and you get logged on. You can increase security with another level by protecting the private key with a passphrase.

Create Key Pair:

$ ssh-keygen -t rsa

Copy Public Key:

Now, once that is completed, we will copy our public key over to the host's authorized_keys file that we like to connect to.

$ ssh-copy-id 192.168.1.10

Once that is done, you should be able to ssh to the target host without providing a password.

Troubleshooting:

If you are running into some issues, have a look at the target host's /etc/ssh/sshd_config that the following line is uncommented:

AuthorizedKeysFile      %h/.ssh/authorized_keys