SSH Password-less authentication in easy steps.

SSH Password-less authentication in easy steps. post thumbnail image

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.

SERVER1 — 192.168.39.1

SERVER2 — 192.168.39.2

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@192.168.39.2 mkdir -p .ssh

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

# cat .ssh/id_rsa.pub | ssh root@192.168.39.2 'cat >> .ssh/authorized_keys'

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

# ssh root@192.168.39.2 "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@192.168.39.2

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

2 thoughts on “SSH Password-less authentication in easy steps.”

  1. Jouni Järvinen says:

    Only works (without conversion) if you don’t need PuTTY/KiTTY (recommend KiTTY, should work under Wine).

    1. Anand says:

      Yes. If you need PuTTY then need to generate .ppk file from the private key.
      Please refer to this article. Click here.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post