Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have tried to configure ssh to use public key authentication

The link

/etc/ssh/sshd_config has got this parameters.

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  .ssh/authorized_keys

PasswordAuthentication yes

But I'm still being prompted for password. If I use

PasswordAuthentication no

I can't login

Any suggestion?


It works but only for root user.

My problem was, I had this parameter

PermitRootLogin no.

I can login with keys with root user if I use

PermitRootLogin yes.

In the system there is only a /root/.ssh directory an authorized_keys file in this directory

How can I add this to other users, if there isn't, in this system, a home/$USER/.ssh directory and authorized_keys file for each user?

Is there a way to configure for each user? I will need diferent authorized_keys files for each user.

Is possible to configure for a different hosts, domains or ips? similar to httpd.conf

share|improve this question
    
Is your public key in .ssh/authorized_keys on the server? Is your private key in one of the standard files in .ssh on your client? –  freiheit Feb 21 '13 at 23:14
add comment

1 Answer 1

Key authentication is always attempted before password authentication, so if you're being prompted for a password then key authentication has failed. The most common cause for this is incorrect ownership or permission on the client and server side files.

On both the client and server, the ~/.ssh directory must be owned and only accessible to you:

chown -R $USER ~/.ssh
chmod u=rwX,g=,o= ~/.ssh

On the client the private key must be owned and only accessible to you:

chmod u=rwX,g=,o= ~/.ssh/id_rsa

On the server the authorized keys file must be owned and only accessible to you:

chmod u=rwX,g=,o= ~/.ssh/authorized_keys
share|improve this answer
2  
ssh-copy-id is a good helper for that. –  Andrew Feb 21 '13 at 23:51
1  
If it still fails afterwards try ssh -v to see what is actually happening and where it is failing. –  scai Feb 22 '13 at 7:42
add comment

Your Answer

 
discard

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.