SSH failed public key authentication

ssh

I have a server, and I want to be able to SSH in with two different users. I have setup public key authentication for the first user, and it works just fine, however, I can't login with the second user.
The difference between the authorized_keys file is that, the second user has two keys(both of them fail when authenticating). Both the .ssh directory and the authorized keys file have 755 permissions. The ssh client sends the key, that I want to authenticate with. What could be the problem?

Best Answer

First, the .ssh directory should have 700 permissions and the authorized_keys file should have 600.

chmod 700 .ssh
chmod 600 .ssh/authorized_keys

In case you created the files with say root for userB then also do:

chown -R userb:userb .ssh

If the problem still persist, then post the output from your ssh log file in your question and I'll update my answer.

For Debian:

less /var/log/auth

For Redhat:

less /var/log/secure
Related Question