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'm getting prompted for a password even though it looks like my SSH key is accepted. As far as I can tell, the line "Server accepts key: pkalg ssh-rsa blen 277" in the logs below mean my key is accepted.

Here are debug logs:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/sam/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp <<HASH REDACTED>>
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/sam/.ssh/id_dsa
debug1: Trying private key: /home/sam/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1

Help much appreciated, everyone I've found who is having SSH problems fails at an earlier point that I'm seeing.

share|improve this question

4 Answers 4

The ssh -v output you pasted suggested that it tried to use the key but that didn't work, so it moved on to keyboard-interactive.

Have you checked the authentication log on the server you are connecting to? (eg, /var/log/auth.log). If your setup at the remote end is incorrect, eg wrong permissions, then ssh -v (or -vv or -vvv) won't tell you this, but it will be logged by sshd.

share|improve this answer

Your private key was most certainly not accepted, it was only attempted. There are a number of ways SSH key based authentication can fail, and the logging is not really that great so debugging this particular problem is one of my personal pet peeves. I've found that the error is usually a result of one of the following situations.

  • Your ~/.ssh/authorized_keys file is too open. For your own protection sshd attempts to protect you from yourself. If the permissions on your authorized keys file then it will fail the authentication. Run chmod -R go-rwx ~/.ssh.
  • Your public key in ~/.ssh/authorized_keys is malformed. This could be a result of any number of problems, but the most common is a copy paste issue. Some terminals, when copy/pasting across screens, will interpret a line wrap as a new line. Each entry in the authorized_keys file must be a single line. You can check this by changing the size of your terminal emulator and seeing if there's a break, comparing the output of wc -l ~/.ssh/authorized_keys against the number of keys that should be in there, or whatever works best for you. Just make sure each key is one line and you should be fine.
share|improve this answer

If you have access to the server (directly or via another login), check the server logs in (say) /var/log/sshd

It is typically caused by a permissions error on your ~/.ssh/authorized_keys file. Make sure it's not world readable, but crucially that it is readable by the user (sometimes a service user) running sshd

share|improve this answer

In my case, file /var/log/authlog showed:

[ID 800047 auth.info] Authentication refused: bad ownership or modes for directory 

I had checked correct ownership/permissions in .ssh but the $HOME had 777 permissions. Setting 755 permissions on $HOME allowed sftp to work. Thanks again.

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.