Here is the situation: I have 4 Linux servers. /home is same for all the four servers. (It's a network drive). I want to setup a password-less SSH via setting up encryption keys. I created RSA key pair using ssh-keygen. Because the /home is same for all users. So I added the public key to authorized key for $HOME/.ssh directory

But when I try to ssh to these servers, it still asks for the password.

Help please!

  • Did you set your permissions right on the files in the .ssh directory. The easiest is to delete them on remote and then use ssh-copy-id. – don.joey Oct 15 '13 at 12:30
  • I moved key pair to home directory, now I have oct15, oct15.pub in $HOME. then "ssh-copy-id -i $HOME/oct15.pub user@machine2". It shows it did something n asks me to check "ssh user@machine2". It still doesnot work. It asks for password – ravidixit Oct 15 '13 at 12:53
  • Please note /home is same for user on all servers. – ravidixit Oct 15 '13 at 12:58
  • can you please run ssh -v to one of the servers, then add the output to your question? – roadmr Oct 15 '13 at 14:25
  • Please confirm that the password request comes from the remote. That is, it reads user@remote's password:, not Enter password for private key:. Also please add the output of ls -al ~/.ssh to your question. – zwets Oct 15 '13 at 19:00

When you enter ssh hostname SSH tries password-based auth by default. So you have to enter an additional option to the command:

ssh -i .ssh/private-key-of-host hostname

After the -i option should be the filename of your key. Now you can login without entering a password.

However there another possibility: You can have a configuration file in .ssh/config. Enter here:

Host Foo
  IdentityFile ~/.ssh/private-key-of-host

Now you can enter ssh Foo and SSH tries to connect to the host mentioned in HostName (can be a IP address or a hostname) with the key from IdentityFile.

  • There is no need to pass -i when you use one of the default keyfiles (identity, id_rsa, etc.). Ssh will try PKI-based authentication in preference to password authentication. – zwets Oct 15 '13 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.