ssh prompts for password despite .ssh/authorized_keys
I found the solution based on @jasonwryan comment under my question.
There was #AuthorizedKeysFile /usr/NX/home/nx/.ssh/authorized_keys2
in the /etc/ssh/sshd_config
sshd config file. Changing the entry to standard AuthorizedKeysFile .ssh/authorized_keys
solved the issue.
In the past, I came across some tutorials that describe how to achieve a ssh password-less setup but some are sadly wrong.
Let's start over again and check every step:
FROM CLIENT - Generate key:
ssh-keygen -t rsa
- Public and private key (
id_rsa.pub
andid_rsa
) will be automatically stored in the~/.ssh/
directory. - Setup will be easier if you use an empty passphrase. If you are not willing to do that, then still follow this guide, but also check the bullet point below.
- Public and private key (
FROM CLIENT - Copy public key to server :
ssh-copy-id user@server
- Client public key will be copied to server's location
~/.ssh/authorized_keys
.
- Client public key will be copied to server's location
- FROM CLIENT - Connect to server:
ssh user@server
Now, if it's still not working after the described 3 steps, let's try the following:
- Check
~/ssh
folder permissions in client and server machine. - Check
/etc/ssh/sshd_config
in the server to ensure thatRSAAuthentication
,PubkeyAuthentication
andUsePAM
options aren't disabled, as they are enabled by default withyes
. - If you entered a passphrase while generating your client key, then you may try
ssh-agent
&ssh-add
to achieve password-less connections in your session. - Check the contents of
/var/log/auth.log
on the server to find the issue why key authentication is skipped at all.