SSH authentication failures: Server refused our key

Posted September 14, 2014 14.5k views

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. is set to mode 600
  8. The user and group are set to the proper user.. what am I missing?
1 comment
  • If NOT logging in as root its also important to make sure that the ownership privileges are set properly in the home directory. Otherwise the user won’t be able to SSH into the server.

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.

Submit an Answer
2 answers

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

I ran dos2unix on my, then cleared out authorizedkeys and then cat >> authorizedkeys…

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

  • Hello Dear,
    can u tell how u did fix that? because my FTP was working but suddbley it said Server refused our key

    i did again generate new key via putty then update into server via command but still not working

    can u help me ?

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.