Question

Putty error: No supported authentication methods available (server sent: publickey)

Posted June 17, 2017 397.6k views
NginxUbuntuLEMPUbuntu 16.04

I am trying to setup a server for my wordpress site. I was going through this tutorial (https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04) to setup ssh keys.
After step five when it says to try logging in with the ssh keys with the newly created user putty returns back with a error saying: “No supported authentication methods available (server sent: publickey)”
I put the public key in the authorized_keys file and everything the tutorial said but it still returns that error. If I try logging in to root with the same private key it works fine. It just shows that error when I try logging in with the new user.

Any help would be appreciated.

3 comments
  • I would also like to mention, I made the keys with Puttygen and I added the public key to digitalocean. I used the key when creating the droplet.

  • I guess you have loaded the .pem file first and then generated the Public key and private key by randomness.

    But if you generate key-pair by randomness and them upload .pem file to generate Public and private key pair then you won’t get this error.

  • Ensure the pubic key is under the user’s home you want to login as.
    You can add here:
    => sudo nano /home/(mynewuser)/.ssh/authorized_keys

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
9 answers

I also had this problem, login from putty as root was fine but from the non-root user gave me the error above. I tried the methods given in the link but it didn’t help, eventually I managed to do it by following this guide: https://www.vultr.com/docs/using-your-ssh-key-to-login-to-non-root-users

This: “No supported authentication methods available (server sent: publickey)” happened to me after I turned on Microsoft One Drive backup and sync for my files including the directory where I save my ssh key. In my case the solution is simple: just go to Putty => SSH => Auth and just (re)browse again to my same key and save, then it worked. It looks backup and sync software such as Microsoft One Drive (and may be the same with Google Drive), affect the way Putty sees and identifies directories if the key directory is specified then later installing or turning on backup and sync including that directory.

Hi,
I resolved this by using PuTYY Generator.
Click Conversion/Import key from the menu
Then select the private key generated previously from the terminal and finally save the new private key.
I used this new generated private key to connect via SSH using putty to the droplet and it works for me.

I never got PuTTY to work, but I was able to use ssh-keygen and ssh root@IP from Git Bash.

@thelunchbawx

The public key generated by puttygen cannot be used directly on Ubuntu you need to change its format as mentioned here

Hope this helps

@thelunchbawx, I am having the exact same problem. Did you figure out a solution?

In my case, I removed default login name from putty and it worked

Hello there,

You can check our article on How to Upload an SSH Public Key to an Existing Droplet

https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/

You can access the droplet from the DigitalOcean console and then temporary enable the PasswordAuthentication on your droplet and access the droplet with a password to upload the ssh-key.

If you haven’t created new pair of keys you’ll need to do that first.

You can enable PasswordAuthentication for your Droplet by modifying your /etc/ssh/sshd_config file. Once set to Yes restart the SSH service and connect via an SSH client for a more stable connection. You can then modify your ~/.ssh/authorized_keys file to add the appropriate public key.

This change can be made from the DigitalOcean’s console. If you’re having issues accessing the console you can then reach to our amazing support team that can help you further with this.

To enable the PasswordAuthentication follow these steps:

  1. Login to the console on the DigitalOcean website.
  2. Type sudo nano /etc/ssh/sshd_config
  3. Change PasswordAuthentication from “no” to “yes” and save the file
  4. Open a terminal on your computer and type ssh username@[hostname or IP address] or if on a Windows box use PuTTY for password login making sure authentication parameters aren’t pointing to a private key
  5. Login with a password
  6. Type sudo nano ~/.ssh/authorized_keys
  7. Paste public key text here and save the file
  8. Type sudo nano /etc/ssh/sshd_config
  9. Change PasswordAuthentication from “yes” to “no” and save the file
  10. Log out and attempt to log back in (if using PuTTY make sure you set up auth parameters to point to your private key)

You can then upload the key using this command:

ssh-copy-id -i ~/.ssh/mykey user@droplet

Hope that this helps!
Regards,
Alex

  • Hi Alex,
    First of all thanks for your guidance on this problem. I have actually been through and tested my setup to try to get to the bottom of it. I have gone back to basics and just trying to login with user and password.
    Checked the ssh config as you suggested - it was commented out so I uncommented it. When I load up the putty settings and click open I dont get a chance to enter anything it just fails with the error straight away.
    Tried turning on logging in putty but all I get is “=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2021.09.27 15:09:18 =~=~=~=~=~=~=~=~=~=~=~=
    Using username "root”.“
    It knows root because my latest attempt was to put it in the autofill box in putty.

    This seems to come up with any of our servers lately but they have all been servers that existed before and I am re-purposing for new use (want to keep the IP address).

    Is there anything else you can advise - I jsut want to be able to login with username and password, not even SSH.

    Regards,
    Mike

I had this issue and I solved it in a very odd way. I notice that my droplet was having issues identifying my public key once I pasted in the SSH public key options in digital ocean, also, I try modify the authorization file in the /.ssh folder by copy pasting the key in there. I notice something interesting, the copy pasting feature on the restoration console in digital ocean seems to be mess up. I notice that while pasting a lot of my keys where confuse for different ones. In my desperation, I went through the taxing task of copying the public key manually in the authorization file and this worked! I hope this save someone from a lot of headaches.