SSH Password-less authentication in easy steps.

SSH Password-less authentication is very useful when you are automating tasks between your all remote servers. If you want to run any script or use SCP multiple times then this option will be very useful for you. Once this is implemented that you will never ask a password to login into that particular server. Of course, It is a secure way because you are giving authentication in between your trusted servers only.

SSH Password-less authentication also use in Ansible architecture to communicate managed nodes from Ansible Engine. I will discuss in detail Ansible articles.

There are simple 4 steps only to implement this authentication. We are authenticating between SERVER1 to SERVER2. Lets see how it works.



Before starting lets check connectivity between SERVER1 to SERVER2.

In the above picture, we can see that SERVER2 asks password to login from SERVER1.

Step 1: Generate SSH-Key in your base system. Which is SERVER1 in our case.

# ssh-keygen -t rsa

Step 2: Now create a .ssh directory on remote server (SERVER2) from SERVER1. Provide a password for SERVER2.

# ssh root@ mkdir -p .ssh

Step 3: Copy generated public key to remote server(SERVER2) .

# cat .ssh/ | ssh root@ 'cat >> .ssh/authorized_keys'

Step 4: Change permissions of remote server’s (SERVER2) .ssh/authorized_keys file.

# ssh root@ "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

If you observed, this time SERVER2 did not ask for password because password less authentication is already established in last step. This time we just changed key file permission.

Step 5: Login SERVER2 without giving password.

 # ssh root@

That’s it. We successfully completed SSH password less authentication. Now whenever you login SERVER2 from SERVER1 it won’t ask password.