Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I generated a key and copied it to my target:

ssh-copy-id username@hostname

I left the the location of the key as default and did not set any passphrase.

For a small while after that, I was able to ssh username@hostname without being prompted for a password, and then it stopped working for some reason.

share|improve this question
See unix.stackexchange.com/tags/ssh/info … Let's make this a reference question that we can close others as a duplicate of. – Gilles Jul 19 '11 at 15:47
up vote 5 down vote accepted

If public key authentication doesn't work: make sure that on the server side, your home directory (~), the ~/.ssh directory, and the ~/.ssh/authorized_keys file, are all writable only by their owner. In particular, none of them must be writable by the group (even if the user is alone in the group). chmod 755 or chmod 700 is ok, chmod 770 is not.

What to check when something is wrong:

  • Run ssh -vvv to see a lot of debugging output. If you post a question asking why you can't connect with ssh, include this output (you may want to anonymize host and user names).
  • If you can, check the server logs, typically in /var/log/daemon.log or /var/log/auth.log or similar.
  • If public key authentication isn't working, check the permissions again, especially the group bit (see above).
share|improve this answer
Hi, why should authorized_keys not be writable by the group ? Does SSH reject this because of security concerns ? – Ydob Emos Apr 15 at 16:10
@YdobEmos Anyone who can write to authorized_keys can add their own key there and thus log into the account. So only the user must be allowed. (Having the file group-writable is actually safe if no other user is in that group, but that's difficult to detect reliably when group memberships can come from network databases.) – Gilles Apr 15 at 16:30

The home directory of the target was 755 drwxr-xr-x. Changing it to be group-writable 775 drwxrwxr-x broke the password-less setup.

share|improve this answer
Same problem did not solved it yet. – YumYumYum Jun 8 '15 at 9:58
You mean you can't get password-less login work, even after making the directory group-writable? – Tshepang Jun 8 '15 at 19:39
YES - please see unix.stackexchange.com/q/208152/11085 , CentOS 7 64-bit where i am trying to login with my id_rsa keys but its always failing. – YumYumYum Jun 9 '15 at 3:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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