Showing posts with label password. Show all posts
Showing posts with label password. Show all posts

Thursday, August 22, 2013

SSH prompting for password even after generating the RSA keys with empty password

I struggled with this issue almost every time I wanted to login to remote hosts without entering the passwords. In some places, I used this solution because I was lazy and in some places it is a requirement such as, Hadoop setup. Anyways, the key to the solution is permissions and the steps are as under:

{USER}@machine1> rm -rf /home/{USER}/.ssh
{USER}@machine2> rm -rf /home/{USER}/.ssh /tmp/id_rsa.pub
{USER}@machine1> ssh-keygen -t rsa [Enter, Enter, Enter]
{USER}@machine1> scp /home/{USER}/.ssh/id_rsa.pub {USER}@machine2:/tmp
{USER}@machine2> mkdir /home/{USER}/.ssh
{USER}@machine2> cat /tmp/id_rsa.pub >> /home/{USER}/.ssh/authorized_keys
{USER}@machine2> chmod -R 700 /home/{USER}/.ssh
{USER}@machine1> chmod 600 /home/{USER}/.ssh/id_rsa*

{USER}@machine2> rm /tmp/id_rsa.pub
{USER}@machine1> chmod 755 /home/{USER}
{USER}@machine2> chmod 755 /home/{USER}


In above steps, replace the {USER} with your user and machine1 and machine2 with appropriate machine ip addresses.h

Please note, the steps marked in BOLD and they should have exactly the same permissions.

Search This Blog