Why do I get Server refused our key when trying to connect using SSH connection with Putty and when everything has been configured according to all the Tutorials?

Generating the pair of keys from Windows Laptop and copying the public key on the RPi authorized_keys file

Configuring Putty

In sshd_config file I open Authorized_keys file

chmod 700 ssh and chmod 600 authorized_keys etc......-

And I always get Server refused our key Googling doesn't help I would really appreciate help.

  • Wondering, could this be related to the Heartbleed bug? Possibly someone re-generated some keys and it threw off the connect-ability. Commented Apr 12, 2014 at 20:57
  • Did you use Putty's converter to convert the openssh key to something that Putty can read?
    – Jacobm001
    Commented Oct 27, 2015 at 18:05

4 Answers 4


Your permissiong are correct. The default location for the authorized_keys file is ${HOME}/.ssh/authorized_keys. Check the permission of the directory containing the ".ssh" directory. It cannot have group or world write permission since that would allow someone else to replace your .ssh directory. Also, PuTTY and ssh use differently formatted private/public keys. I use PuTTYgen to create the PuTTY private key saved in a .ppk file and then copy the OpenSSH authorized key and paste that into the authorized_keys file. It will look something like ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAp1hWgFhD6ZWgcfUrY0+zcWas7uH252TMXGWynwZBoTriF8a9Vlo3+NfPNc2xsSvqzJs2fD5LOw1YZe2DGfazBM313vtUKg6aozBsSavYi7o6f/BZPlCh2NZKmLTFB3E0Y0m+ZE3bQXM+rn5dAqb+SU26vgwLKBvarm4tYew87FB1AIDHzFLSDECb7JoEfcpOp8A5yLW97TTaJZAl5mVlig2HeeKrj6zLGxPoK7T0MXxcNbb1arU0LCHfQxIKj+f7T8pHyDMH5ybz2ij52KBMj9HNlQGjZ3Cg7DU7/dNFBWXbn5xedcx9MnycqpulQd6IL8oY3xVWwxpsVhd+MR2GBw== rsa-key-20140419

It should be all on one line in the authorized key file. Typos in public key are another common cause for problems. I have not had to change the configuration for the ssh daemon.


I had the same issue of "Server refused our key". I found out the problem was using sudo nano authorized_keys.

I used nano authorized_keys instead and it worked. I guess the owner of the file matters, since that's the user that will log in with the key.


It's been a while, but I also wanted to add that setting correct permissions for my user directory (e.g. /home/<user>) was important in making this work. In /var/log/auth.log, I found Authentication refused: bad ownership or modes for directory /home/<user>.

Alongside the requisite permissions for the subfolder /.ssh and the file authorized_keys mentioned, it also needed drwxr-xr-x permissions which was resolved by chmod go-w /home/<user>.

  • 1
    Giving read permissions to everyone on a home folder seems odd. Commented Jan 12, 2021 at 9:05

I don't know who will need this but here's my share of the problem and it's solution:

Problem: Firstly, I managed to setup an SSH connection from my Windows PC via PuTTY with a fresh copy of Raspbian (Feb-23) on Raspberry Pi 3 B+. After few on and off sessions i wanted to automatically login without constantly typing my password (my project requires a lot of hard resets to RPI). After following the first couple of internet manuals, all were telling me the same: 1) Use PuTTY keygen, save keys. 2) On RPI, create .ssh/ folder 3)Inside .ssh/ create a file named authorized_keys with the public key string from PuTTY. 4)Load private key to PuTTY login profile.

That didn't work for me no matter what I tried, i even got as far as putting my .ssh folder in the above-root directory! Still got message "Server refused our key".

By the way i transferred the public key using scp command via Windows PowerShell and gave it all possible permissions and owners.

Solution: I figured let's try backward approach:

  1. In your Raspbian console type:


and hit 'Enter' 3 times (unless you want to setup extra security).

  1. The program created .ssh/ directory in your home/username/ directory with 2 files: a)id_rsa b)id_rsa.pub - one contains the private key and the other the public key respectively.

  2. Type:

cat id_rsa

copy private key content from the console and save as a blank file format on your pc using a text editor. Name of file is not critical.

Important: the private key must include the:





  1. In console type:

mv id_rsa.pub authorized_keys

chmod 644 authorized_keys

  • This changes the name of the public key file to "authorized_keys" and gives it security sufficient permissions.
  1. In Windows, load PuTTYgen, in menu: click Conversions->Import key , and browse for the saved private key file.

  2. Click "Save private key" as PuTTY format .ppk .

  3. Load .ppk file into your SSH profile: SSH->Auth->Credentials.

  4. Don't forget to save your SSH profile and you're good to go!

My guess is that PuTTY's default Keygen settings are not compatible with current Raspbian protocol encryption-wise. But let the experts do the digging :P

  • This is an inspired idea and totally worked for me. This was on a Ubuntu 22.10 machine for those interested. Don't forget to edit the /etc/ssh/sshd_config file to set PasswordAuthentication no and restart ssh systemctl restart ssh otherwise password authentication still works and then what is the point :) Thanks so much.
    – gfmoore
    Commented Apr 26, 2023 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.