0

I'm connecting to a remote server as tom who (obviously) exists on the remote server but not the local server.

I copied the id_rsa.pub key generated for local user bob onto tom's authorized_keys file on the remote server. However, I'm still being prompted for the password.

[bob@localserver ~]$ ssh tom@remoteserver

EDIT 1

Just for completeness I also regenerated the the key and copying it to the remote server.

ssh-keygen -t rsa
ssh-copy-id -i tom@REMOTESERVER

See debug output here: ssh debug details

I noticed the following in the debug output. This is present for every line (base64 block?) in my id_rsa private key file:

debug3: key_read: missing whitespace

EDIT 2:

Remote server's permissions:

drwx------ 2 tom tom 4096 Aug 15 10:59 .
drwx------ 5 tom tom 4096 Aug 15 11:54 ..
-rw-rw-r-- 1 tom tom  810 Aug 15 10:59 authorized_keys
-rwx------ 1 tom tom  109 Aug 14 09:43 config
-rw------- 1 tom tom 1675 Aug  8 14:58 id_rsa
-rw-r--r-- 1 tom tom  404 Aug  8 14:58 id_rsa.pub
-rw-r--r-- 1 tom tom 1217 Aug 10 09:32 known_hosts

Local server's permissions:

drwx------ 2 bob bob 4096 Aug 15 11:32 .
drwx------ 7 bob bob 4096 Aug 15 11:32 ..
-rw------- 1 bob bob 1613 Aug 15 11:09 id_rsa
-rw------- 1 bob bob 1675 Aug 15 11:08 id_rsa.bkp
-rw-r--r-- 1 bob bob  405 Aug 15 10:58 id_rsa.pub
-rw-r--r-- 1 bob bob  410 Aug 15 10:59 known_hosts
  • 3
    Look at the output of ssh -vvv tom@remoteserver. – garethTheRed Aug 14 '14 at 5:49
  • Also please add the output of ls -la ~/.ssh on the server. – michas Aug 15 '14 at 12:40
  • updated with permission details. – kaizenCoder Aug 17 '14 at 3:09
2

Your output of ssh -vv tom@remoteserver contains:

debug1: Offering public key: /home/bob/.ssh/id_rsa

At this point the client found your private key and tries to authenticate with it. - However the server refuses to do so. The reason might be found it server log.

Wild guess: you have a file permission problem.

Double check the correct permissions on the server ls -la ~/.ssh. Even better: Use ssh-copy-id to copy the public key to the remote server. It will take care of the correct permissions.

man sshd_config says:

   StrictModes
          Specifies whether sshd(8) should check file modes and ownership  of  the
          user's  files  and  home directory before accepting login.  This is nor‐
          mally desirable  because  novices  sometimes  accidentally  leave  their
          directory  or  files world-writable.  The default is ``yes''.  Note that
          this does not apply to ChrootDirectory, whose permissions and  ownership
          are checked unconditionally.

Basically only the user itself should be able to read/write to ~/.ssh.

  • StrictModes is commented out in the remote server. I will attach the debug info shortly. – kaizenCoder Aug 15 '14 at 1:21
  • If it is commented out, it defaults to yes and will therefore be activated. – michas Aug 15 '14 at 12:37
  • 1
    And to check the server log, it is often easiest to start a new server (in debug mode) on a different port. As an example: # /usr/sbin/sshd -d -p 2222, then from your client add '-p 2222' on the line. This gets you a debug log without restarting your main sshd. – BowlOfRed Aug 17 '14 at 3:15
0

Try with permission 600 for authorized_keys file on remote host. 644 is fine too but it should not be group and/or other writable.

Helpful link :

https://stackoverflow.com/questions/5698665/strange-that-ssh-authorized-keys-will-not-work-if-it-is-a-chmod-of-664

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.