How to do Passwordless SSH

I have recently faced a scenario where it requires me to do passwordless SSH on a remote machine and again do the passwordless SSH on the same remote machine.

Here is the scenario,

My VM ==> Remote Machine==> Then do passwordless ssh on Remote Machine

As a first part, I have configured the Passwordless SSH on Remote machine by following the below steps,

1. Run ssh-keygen -t dsa -f ~/.ssh/id_dsa to generate public and private key pair
2. Run ssh-copy-id USERNAME@REMOTE_MACHINE to copy the keys to remote machine
3. The login into REMOTE_MACHINE and go to /home/USERNAME/.ssh and check the authorized_keys file and make sure that the key is there with REMOTE_MACHINE.local
4. Then run ssh USERNAME@REMOTE_MACHINE to verify it

This works fine. But once I login into REMOTE_MACHINE when i try to run ‘ssh USERNAME@REMOTE_MACHINE’. Its asking me the password again. So to enable the password less SSH, I have followed the below steps

1. Login into REMOTE_MACHINE
2. Then generate the keys ssh-keygen -t dsa -P ” -f ~/.ssh/id_dsa
3. Then run this cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s