SSH Public Key - No supported authentication methods available (server sent public key)

Posted by F21 on Ask Ubuntu See other posts from Ask Ubuntu or by F21
Published on 2012-10-22T01:10:02Z Indexed on 2012/11/01 5:17 UTC
Read the original article Hit count: 2506

Filed under:

I have a 12.10 server setup in a virtual machine with its network set to bridged (essentially will be seen as a computer connected to my switch).

I installed opensshd via apt-get and was able to connect to the server using putty with my username and password.

I then set about trying to get it to use public/private key authentication. I did the following:

  1. Generated the keys using PuttyGen.
  2. Moved the public key to /etc/ssh/myusername/authorized_keys (I am using encrypted home directories).
  3. Set up sshd_config like so:

    PubkeyAuthentication yes

    AuthorizedKeysFile /etc/ssh/%u/authorized_keys

    StrictModes no

    PasswordAuthentication no

    UsePAM yes

When I connect using putty or WinSCP, I get an error saying No supported authentication methods available (server sent public key).

If I run sshd in debug mode, I see:

PAM: initializing for "username"
PAM: setting PAM_RHOST to ""
PAM: setting PAM_TTY to "ssh"
userauth-request for user username service ssh-connection method publickey [preauth]
attempt 1 failures 0 [preauth]
test whether pkalg/pkblob are acceptable [preauth[
Checking blacklist file /usr/share/ssh/blacklist.RSA-1023
Checking blacklist file /etc/ssh/blacklist.RSA-1023
temporarily_use_uid: 1000/1000 (e=0/0)
trying public key file /etc/ssh/username/authorized_keys
fd4 clearing O_NONBLOCK
restore_uid: 0/0
Failed publickey for username from port 14343 ssh2
Received disconnect from 14: No supported authentication methods available [preauth]
do_cleanup [preauth]
monitor_read_log: child log fd closed
PAM: cleanup

Why is this happening and how can I fix this?

© Ask Ubuntu or respective owner

Related posts about ssh