SSH failed public key authentication

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

I have found this message in /var/log/auth.log:

Oct 22 13:27:58 hagyma sshd[27420]: User userb not allowed because account is locked

I have set a password for userb with sudo passwd userb, and it unlocked the account.


For me, sshd was ignoring ~/.ssh/authorized_keys because /home partition was mounted in an unusual way. I tried everything, I set the correct permisions, and it worked only after modifying in sshd_config:

StrictModes no

Tags:

Ssh