Wednesday, 24 April 2013

Unix:Password less ssh not working

If you have setup password less ssh and its not working.

Check the permissions on .ssh directory and files inside it.


drwxr-xr-x  2 user grp  512 Apr 10 02:30 .ssh
-rw-r--r--  1 user grp 1674 Apr 10 02:29 .ssh/authorized_keys
Also  home directory should be writable to user itself .

If that is fine then it can be issue with ssh-agent

Try the following commands :

$ssh-add
Identity added:

If it works successfully then you password less ssh would start working . However if you get some error like

Could not open a connection to your authentication agent.

Then generate a new pid for ssh-agent as following:

$eval `ssh-agent`
$ssh-add

It will help

Steps for setting password less ssh

Create a key:

ssh-keygen

The key will be placed in ~/.ssh/id_rsa.pub file.
____________________________________________

Password Less SSH with Remote Host:

ssh-copy-id -i ~/.ssh/id_rsa.pub remoteuser@remotehost
$ssh-copy-id -i ~/.ssh/id_rsa.pub user@192.168.213.38

It will append the contents of 'id_rsa.pub' to 'authorized_keys" on remote.
____________________________________________

Password Less SSH with Self:

ssh-copy-id -i ~/.ssh/id_rsa.pub localhost@selfIPorName
$ssh-copy-id -i ~/.ssh/id_rsa.pub user@ip



No comments:

Post a Comment