Tuesday, 29 November 2016

How to Enable Passwordless Authentication with SSH

Note: - Node1 is the source and Node2 will be the destination machine.

Step 1: Create directory .ssh on node1 if not exist:

[root@linuxcnf ~]#mkdir ~/.ssh

Step 2: Enter in to the directory node1:

[root@linuxcnf ~]# cd ~/.ssh

Step 3: Generate key pair in Node1 source machine:

[root@linuxcnf ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
0c:9f:09:e6:89:5a:cb:86:45:c6:89:9f:7c:df:1b:00 root@linuxcnf

Step 4: Copy key to Node2 destination machine:

[root@linuxcnf ~]# scp ~/.ssh/id_rsa.pub user1@node2:/home/user1/id_rsa.server1.pub

Step 5: Login on remote node2 machine:

[root@linuxcnf ~]# ssh user1@node2

Step 6: Create directory .ssh on node2 if not exist:

[root@linuxcnf ~]# mkdir .ssh

Step 7: Change directory permission:

[root@linuxcnf ~]# chmod 700 .ssh

Step 8: Move key in to .ssh/authorized_keys:

[root@linuxcnf ~]# cat id_rsa.server1.pub >> .ssh/authorized_keys

Step 9: Change key file permission:

[root@linuxcnf ~]# chmod 644 .ssh/authorzied_keys

Step 10: Logout from the remote server:

[root@linuxcnf ~]# logout

Step 11: Login in to remote server without password:

[root@linuxcnf ~]# ssh user1@node2

It’s Done!!

No comments:

Post a comment