I'm connecting from machine M1 to machine M2 using ssh (to the same user on the other machine). I should also mention the user shares the same key on both machines. With password authentication, everything works fine; not so with public-key authentication; I've ensured ~/.ssh/authorized_keys
on M2 has the RSA key as authorized, but still - ssh falls back to password authentication. I get the following with ssh -vvv
:
debug2: key: /home/joeuser/.ssh/id_rsa (0x7f42679e8200),
debug2: key: /home/joeuser/.ssh/id_dsa ((nil)),
debug2: key: /home/joeuser/.ssh/id_ecdsa ((nil)),
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/joeuser/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/joeuser/.ssh/id_dsa
debug3: no such identity: /home/joeuser/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/joeuser/.ssh/id_ecdsa
debug3: no such identity: /home/joeuser/.ssh/id_ecdsa: No such file or directory
debug2: we did not send a packet, disable method
I should mention that I am able to connect using public-key authentication from other machines (not with the same key).
What are the potential reasons for key-based authentication failing in this case?
Note: The machines are both SLES (SuSE Linux Enterprise Server) 11.
Check the basics:
The error you get is
Make sure this file exists, contains the private key that corresponds to the public key that you've added, belongs to
joeuser
and has600
user permissions:You should also try to explicitly define the private key like this:
If you are not sure if this is the right key then I'd recommend to create a new RSA key pair
and add the content of the public key
~/.ssh/id_rsa.pub
to the authorized_keys file of the remote server. Make sure that you don't overwrite an existing private key that you still need to login to other servers!