2

This post is following this question : Authentication refused: bad ownership or modes for file /var/git/.ssh/authorized_keys .

The issue as exposed there is solved (about files modes of the .ssh folder.

But an other issue persists so I create a new question :

When I try to login (with verbose options), all seems to work fine but at the end, here is what happened :

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/remi/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/remi/.ssh/id_dsa
debug1: Trying private key: /home/remi/.ssh/id_ecdsa
debug1: Trying private key: /home/remi/.ssh/id_ed25519
debug2: we did not send a packet, disable method
debug1: Next authentication method: password

I don't understand because these lines seems to be a non-sense for me :

  • we sent a publickey packet, wait for reply
  • we did not send a packet, disable method
  • Good idea for separate question. I'm looking at my (successful) login's debug output. I see "we did not send a packet, disable method for dsa and we send a publickey packet, wait for reply for rsa. How absolutely certain are you the keys on server and client are correctly paired?? – Otheus May 27 '15 at 10:40
  • It indicates that the SSH server cannot access the authorized_keys file... Does your SSH server run under another account than root? – user86969 May 27 '15 at 11:40
  • @Otheus I just checked again, the pair matches – Rémi B. May 27 '15 at 12:02
  • @Nasha Yes, login with other users works. For example, login with the same username as the client works fine – Rémi B. May 27 '15 at 12:02
  • 1
    Interesting. I don't see a line such as debug2: key: /home/remi/.ssh/id_rsa (0x7fb7031da7e0). That might have been in the output above the point you posted. Set StrictModes=no on the server and try again. After testing, remove it again. At least it will tell us which direction the problem lies. – Otheus May 27 '15 at 13:21
5

You will get this behaviour if the file mode of the user's home directory on the destination host is not set correctly. It's not just the mode of the .ssh directory that has to be correctly set!

ssh to the host and give your password to login, then

chmod 755 ~
logout

Then ssh again and assuming you have everything else set up correctly (see the other answers), you should be able to login.

This is what it looks like when the home directory is wide open (777). Note that it doesn't try the rsa key:

ssh -v user@host
...
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/iwoolf/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/iwoolf/.ssh/id_dsa
debug1: Trying private key: /home/iwoolf/.ssh/id_ecdsa
debug1: Trying private key: /home/iwoolf/.ssh/id_ed25519
debug1: Next authentication method: password
...

Then with the home directory permissions set correctly (755):

ssh -v user@host
...
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/iwoolf/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
1

I made the mistake of naming my public and private key a non-standard name. Changing it back to "id_rsa" fixed the problem for me.

  • You can use different keys for login if you use appropriate options in ~/.ssh/config, like IdentityFile ~/.ssh/key2 in a Host myhost2 section. – Ned64 Nov 3 '17 at 15:16
1

I had a similar problem that resolved when is changed StrictModes from yes to no.

  • 1
    This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – peterh Dec 1 '17 at 18:26
  • @peterh This looks okay doesn't it? – Sparhawk Dec 1 '17 at 22:48
0

Is the server configured to accept RSA keys?

Ensure RSAAuthentication yes is in sshd_config file.

  • Yes, login with other users works. For example, login with the same username as the client works fine – Rémi B. May 27 '15 at 11:50
0

I ran into a problem where I'd get we did not send a packet, disable method because the private key file did not have a newline (\n) at the end of the last line.

This was for an Ed25519 key, not RSA (with an RSA private key, I did not experience this problem!).

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.