Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have set passwordless connection from user A on my server to two other users. SSH to one of them works fine, but to the other one it asks for password.
As far as I can tell, both users are the same with ssh files, permissions, etc. setting StrictModes no and UsePAM no didn't help.

In /var/log/secure I see for the first user:

debug1: trying public key file /home/testb/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug1: matching key found: file /home/testb/.ssh/authorized_keys, line 1

And for the second (/myuser/app/ is ~):

debug1: trying public key file /myuser/app/.ssh/authorized_keys
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 1500/1500 (e=0/0)
debug1: trying public key file /myuser/app/.ssh/authorized_keys
debug1: restore_uid: 0/0
Failed publickey for myuser from ::1 port 38888 ssh2

authorized_keys file is the same for both.

Any help would be appreciated.

Eran.

share|improve this question
    
Why are you using ssh to log onto the server you are already logged on to? Is there a specific reason or do you just want to change users? –  terdon Mar 17 '13 at 15:43
    
It's within a script that usually do ssh to another server. In this specific configuration, both are on same server. –  Eran Ben-Natan Mar 18 '13 at 9:13

2 Answers 2

Please check if the file /myuser/app/.ssh/authorized_keys has the correct owner and permissions.

It should be readable only for the owner (here: myuser)

    chown myuser /myuser/app/.ssh/authorized_keys
    chmod 600 /myuser/app/.ssh/authorized_keys
share|improve this answer
    
also make sure, wherever your .ssh subdirectory is, it has 700 permissions as well as your user's home directory is not writable by any anyone but the user itself. –  MelBurslan Mar 17 '13 at 18:32
    
Thank you both. Permissions are already set as you suggested. However, Permissions are the same for the user I can connect and the one I can't. This is what strange here. –  Eran Ben-Natan Mar 18 '13 at 9:19

I finally found this: http://bugs.centos.org/print_bug_page.php?bug_id=4959

So I run

restorecon -R -v /root/.ssh

And the problem solved!

share|improve this answer

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.