SSH login without password in Linux


Normally, we will login to the remote server using user name and password at the time of authentication.

But here, we can login to the remote server without knowing user name and password of the server using ssh keys. This will be helpful when we need to pull some information or do some task in multiple servers at a time from a particular server. This can be done in  3 simple steps.

In this example, I’m using node1 and node2 servers, will login to node2 without providing any password from node1.

Step 1 :

Generate the RSA key in node1 as a root user. Accept the default values.

[root@node1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): <Enter>
Enter passphrase (empty for no passphrase): <Enter>
Enter same passphrase again: <Enter>
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
ff:bc:21:ed:c2:03:fa:0c:1d:3e:ab:60:e6:56:fc:ee root@node1

Step 2:

Copy the file /root/.ssh/ key to node2.

[root@node1 Desktop]# ssh-copy-id -i /root/.ssh/ root@node2

root@ramesh's password:
Now try logging into the machine, with "ssh 'root@ramesh'", and check in:


to make sure we haven't added extra keys that you weren't expecting.

Step 3 :

Now you can login to node2 from node1 as root user without providing any password.

[root@node1 Desktop]# ssh node2
Last login: Tue Nov  8 15:39:32 2016 from
[root@node2 ~]# uptime
15:42:21 up 5 days, 18:01,  2 users,  load average: 0.00, 0.00, 0.00

Recommended For You

About the Author: admin

Leave a Reply

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

Subscribe To Our Newsletter
Subscribe to our email newsletter today to receive updates on the latest news, tutorials and special offers!
No Thanks
Thanks for signing up. You must confirm your email address before we can send you. Please check your email and follow the instructions.
We respect your privacy. Your information is safe and will never be shared.
Don't miss out. Subscribe today.
WordPress Popup Plugin