Strovent SystemsSign in
Reference

PuTTY "Server refused our key": why and how to fix it

PuTTY offered your public key and the server said no before any passphrase prompt. Usual causes: key not in authorized_keys, file modes, wrong user, ssh-rsa.

Server refused our key

PuTTY prints this when it offered a public key and the server would not accept it for that account. In SSH, a client may first ask "would you accept this key?" without signing anything (RFC 4252, section 7). PuTTY does that, and asks for your key's passphrase only after the server says yes. So when you see this line, the passphrase was never the problem, and PuTTY moves on to the next method, for example a password prompt, or, if the server allows only keys, PuTTY "No supported authentication methods available (server sent: publickey)".

For keys held in Pageant, the same refusal appears only in the Event Log (system menu, then Event Log), not in the window.

The PuTTY manual says this is almost certainly not a problem with PuTTY, and advises checking the server's configuration first.

Causes on the server

  • The public key is not in that account's authorized_keys. The server checks ~/.ssh/authorized_keys of the user you log in as. Check the user name in the login as: prompt or under Connection, Data.
  • The key was pasted in the wrong format. OpenSSH wants each key on one line, starting with the key type, for example ssh-ed25519 AAAA.... Copy it from PuTTYgen's "Public key for pasting into OpenSSH authorized_keys file" box. The file from PuTTYgen's Save public key button is in the RFC 4716 format (it starts with ---- BEGIN SSH2 PUBLIC KEY ---- and spans several lines), which OpenSSH does not read in authorized_keys. On the server, ssh-keygen -i -f key.pub prints such a file as one OpenSSH line. A line broken in two by the editor fails the same way.
  • File permissions or ownership. With StrictModes on (the default), the server ignores authorized_keys if it, the .ssh folder or the home folder is writable by group or others, or owned by someone else. The PuTTY manual suggests chmod go-w $HOME $HOME/.ssh $HOME/.ssh/authorized_keys. Details are in Authorized keys and permissions.
  • The key type is not accepted. OpenSSH 8.8 and later refuse RSA signatures made with SHA-1 (ssh-rsa) by default. An older PuTTY that signs RSA keys only that way is refused. Update PuTTY, or use an Ed25519 key. See SSH "sign_and_send_pubkey: no mutual signature supported" for the same problem from the OpenSSH side.
  • The server looks somewhere else for keys. AuthorizedKeysFile or AuthorizedKeysCommand in sshd_config can point to another file or a directory service, and a from= option on the key line limits where it may be used from.

Read the server log

If you can get in another way, the server's log can say why. On systemd hosts, journalctl -u ssh or journalctl -u sshd shows it. Two lines OpenSSH writes at its default log level (some versions add [preauth] at the end):

Authentication refused: bad ownership or modes for directory /home/user1/.ssh
userauth_pubkey: signature algorithm ssh-rsa not in PubkeyAcceptedAlgorithms

The first means fix the modes. The second means the RSA signature type is the problem.

Causes on your side

  • The wrong key. The session's key file, or the first keys in Pageant, are not the one the server knows. With many keys in Pageant you can also hit the server's limit on attempts; see SSH "Too many authentication failures". Setting the right key file makes PuTTY use only that key from Pageant.
  • The key file is not a PuTTY key. If the window shows "Unable to use key file" or "Unable to load key file" before this line, PuTTY could not read the file and offered nothing from it. Convert it in PuTTYgen; see Convert a PuTTY .ppk key to OpenSSH format, and PPK version 3.

Sources

Spotted a mistake? Email [email protected].