Report this

What is the reason for this report?

SSH authentication failures: Server refused our key

Posted on September 14, 2014

I have set up public key authentication before and never had this much trouble… I am not sure what I am missing, but I have done all of the following:

  1. Ensured the private and public key match (they were created by puttygen, and i use the same key for github )
  2. PubkeyAuthentication is set to yes
  3. AuthorizedKeysFile %h/.ssh/authorized_keys
  4. AuthorizedKeysFile has my public key in it.
  5. AuthorizedKeysFile is set to mode 600 (i’ve tried 644, 700, 777… i know ssh server usually blocks any attempt to use these if permissions are too open, but idk what else to try)
  6. ~/.ssh is set to mode 700
  7. id_rsa.pub is set to mode 600
  8. The user and group are set to the proper user… what am I missing?


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Ok… apparently it was an issue with copying the file over a remote connection.

I ran dos2unix on my id_rsa.pub, then cleared out authorized_keys and then cat id_rsa.pub >> authorized_keys…

boom, it works. Thanks to DEBUG3. (Why doesn’t verbose give key failure information…?)

I also had this same issue.

I solved it by

  1. Running puttygen
  2. Loading the private key I had generated
  3. Copying “Public key for pasting into OpenSSH authorized_keys file” into a new pub_key.txt file locally
  4. Using winscp to copy that file up to my server under the .ssh folder
  5. Deleting the authorized_keys file via rm authorized_keys
  6. Installing dos2unix via sudo apt-get dos2unix (I’m running Ubuntu)
  7. Converting the windows generated file to unix style line endings via dos2unix pub_key.txt
  8. Copying the pub key into authorized_keys via cat pub_key.txt >> authorized_keys

This finally allowed me to putty into my box as all the tutorials described.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.