This was working fine but not sure suddenly stopped working.

I have added my id_rsa.pub key of localhost to authorized_keys of .ssh folder on server. When I try to login to server (running ubuntu 12.10) from localhsot with

ssh account@ip

it asks for password. I am not sure what I am doing wrong since it looks to be pretty straight forward process and it was working fine earlier. Any help ?

  • check by adding public key in known_hosts file. – Tingrammer Jun 12 '14 at 13:36
  • @Tingrammer: The known_hosts file is for the purpose of the connector in making sure the server they're connecting to is correct. This shouldn't influence what authentication method is used by the server. – saiarcot895 Jun 12 '14 at 14:17
  • 1
    Have you tried using ssh-copy-id? – saiarcot895 Jun 12 '14 at 14:18
  • Have you had a look into the /var/log/auth.log ? Do you see error/warning related to SSH ? – Benoit Jun 12 '14 at 20:26

There could be any number of problems from incorrect permissions to an encrypted home directory.

In general, ssh-copy-id is the best method to transfer the keys as it automates the process.

ssh-copy-id -i key_name user@server

See http://bodhizazen.com/Tutorials/SSH_keys#Transfer for details

If you are using an encrypted home directory, however, you need to configure your ssh server to look for the keys in an alternate location. In that event, you edit /etc/ssh/sshd_config and edit the location of the key file.

If all that fails, post the output of

ssh -vvv user@server

the -vvv option will show verbose error messages.


I had the same issue. In my environment I had two accounts (acct1 and acct2) I set up my ssh keys in acct1 and it worked properly.

Then I copied the .ssh directory from acct1 to acct2 and tried it there, but it didn't work as expected, asked me for the password...

The reason was: The ownership of the files in .ssh directory. The acct2 user was not the owner of those files.

-rw-------  1 root   root    408 Aug 10 16:53 id_rsa.pub

-rw-------  1 **root**   **root**   1675 Aug 10 16:53 id_rsa

-rw-r--r--  1 acct2 acct2  444 Aug 10 16:54 known_hosts

So I just changed the ownership of files to acct2 user.

sudo chown acct2:acct2

Now it look like below and it works properly.

-rw-------  1 acct2   acct2    408 Aug 10 16:53 id_rsa.pub

-rw-------  1 **acct2**   **acct2**   1675 Aug 10 16:53 id_rsa

-rw-r--r--  1 acct2 acct2  444 Aug 10 16:54 known_hosts

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.