Passwordless ssh login in RedHat6

Posted by Md. Mahidul Hasan on 12:08 AM with No comments
Passwordless ssh login in RedHat6

1.1. First install openssh to both machine:
[root@vpn ~]# yum install openssh*

1.2. Now create a pair of keys one is public (id_rsa.pub) and other is private key (id_rsa).
[root@vpn ~]# ssh-keygen -t dsa
[root@vpn ~]# ls -l /root/.ssh/
-rw-------. 1 root root 1675 Sep 27 23:49 id_rsa
-rw-r--r--. 1 root root  402 Sep 27 23:49 id_rsa.pub

1.3. Now keep the public key to the destination server where you want to login passwordlessly. To do so use the below command. here my remote server's ip address is 192.168.1.73
[root@vpn ~]# ssh-copy-id root@192.168.1.73
Now try logging into the machine, with "ssh 'root@192.168.1.73'", and check in:
  .ssh/authorized_keys

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

1.4. Lets check its works or not:
[root@vpn ~]# ssh root@192.168.1.73

1.5. Troubleshooting: 
Sometime you may get the below error:
[root@vpn ~]# ssh-copy-id root@192.168.1.73
/usr/bin/ssh-copy-id: ERROR: No identities found

And this is how you should fix the problem:
[root@vpn ~]# ssh-agent $SHELL
[root@vpn ~]# ssh-add -L
[root@vpn ~]# ssh-add

Sometimes it may also gives an error like- "Could not open a connection to your authentication agent". To remove this error, use the following command.
[root@vpn ~]# eval `ssh-agent`

[root@vpn ~]# ssh-add -L
[root@vpn ~]# ssh-copy-id root@192.168.1.72
[root@vpn ~]# ssh root@192.168.1.72

Well all done. See, how easy was that !!! :D