Howto: Password-less SSH login

This is a short one for beginners. What do you have to do to make password-less SSH connections work?
Imagine that you have two cluster nodes(node1, node2), that need to talk to each other via SSH. The Veritas Cluster installation requires this functionality and will not start until it has been applied to all of the cluster nodes.
1. Login to node1 as the user that should be able to login to node2.
2. execute ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/juergen/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/juergen/.ssh/id_rsa.
Your public key has been saved in /home/juergen/.ssh/
The key fingerprint is:
a4:33:48:28:25:bd:3c:6e:23:21:7a:fc:3a:cc:20:15 juergen@node1

3. A new private/public key pair has been created. Copy the public key to the second node.
scp ~/.ssh/ node2:/home/juergen/node1.key
4. Login to node2 with the same username that you’ve used on node1.
5. Redo steps 2-3 accordingly.
5. Add the public key of node1 to the list of trusted host keys.
cat ~/node1.key >> ~/.ssh/authorized_keys
6. Check that the key exists in the authorized_keys file.
cat ~/.ssh/authorized_keys
7. Remove the copy of node1’s public key from node2.
rm -f ~/node1.key
8. Redo steps 5-7 on node1 accordingly.
9. Check that it works.
From node1 ssh node2
From node2 ssh node1

…. done

About Juergen Caris

I am 54yo, MSc(Dist) and BSc in Computer Science, German and working as a Senior Server Engineer for the NHS Lothian. I am responsible for the patient management system, called TrakCare. I am a UNIX/Linux guy, working in this sector for more than 20 years now. I am also interested in robotics, microprocessors, system monitoring, Home automation and programming.
This entry was posted in Beginner, Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published.