How to Set Up a Password-less SSH Login

SSH or Secure Shell protocol allows two ways of authentication, one is the usual user name/password combination, and the other is use of a pair of public/private keys. These keys need to be generated and appended to on the remote server to allow for password-less SSH login. In this tutorial we will guide you on how to set up a password-less ssh login.

Step#1: Generating Keys
Let us open up the terminal application and type the command ssh-keygen –t rsa
This command initiates the creation of a key pair. Both the public and the private keys will be generated with this. The contents of the private key are read only and only meant for you. This key will be used to decrypt all interactions encrypted by the public key.
creating a pair of public/private keys

Step#2: Updating the SSH keys
Now, let’s clear the screen and type the command ssh-add. This command will basically add the generated key to the ssh directory.
adding keys to SSH configuration

Step#3: Verifying Password-less Login
Finally go to SSH login to access the local server to check whether we are prompted for the password while logging in. For that, let’s use the command ssh root@localhost
And there you have it, a password-less SSH login session. Notice that the ssh session has now been connected without prompting you for the password
logging in without a apssword