Question

ssh : Permission denied (publickey)

Dear !!

I created droplet 2 weeks ago. I followed the using ssh guide, creating ssh key, adding ssh key for security on digitalocean. I have logined the system everyday since setup.

But Today I try . : ssh root@IP address, I found the following message. Permission denied (publickey).

I searched all question, but not working.

Please help me.

Subscribe
Share

I created droplet today but i can’t access with ssh. when i run: ssh user@ip_addr it return Permission denied (publickey). what can i do to solve that?


Submit an 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.

For others looking for more information, refer to this document on the DO Docs: Manually from the Droplet without Password-Based Access Any SSH public keys that you add to you DO account (in Account > Settings > Security tab) are only applied to the droplet when it is created. If you already have a droplet up and running and you are trying to add any additional SSH public keys you will have to follow the article I linked above. It helped me solve the problem of “Permission denied (publickey)”

When I created my very first droplet, I encountered the same error.

The solution was: 0. Generate a keypair in localhost using “ssh-keygen” and press <Enter> for the rest.

  1. Add a public key to your account settings with name “id_rsa.pub”.
  2. Create the droplet after <1>. Make sure to check the checkbox to use existing pub key.
  3. After droplet creation, log in as usual “ssh root@<droplet_ip>”

Hope it helps. Vu

I had same issue & I found this link. https://medium.com/@hidace/how-to-ssh-into-a-digitalocean-server-after-getting-permission-denied-publickey-error-77b687c2880d

Do you have multiple ssh-keys on your computer? you might wanna check if you have added your ssh key to your agent with ‘ssh-add -L’

I had same issue couple days ago. My problem was name of public key, I just rename public key to id_rsa and it works again.

Try with ssh -vvv root@IP address and see what is your problem with login.

Hello, Don’t forget modes and ownership in source and destination:

0700 user:user for .ssh 0644 user:user for .ssh/authorized_keys and .ssh/known_hosts 0600 user:user for .ssh/id_rsa

It’s very important and if is not like that you may have this error

Hello there. Any updates with this question? I ran into the same issue today. I have used my ssh key for few weeks… and it worked fine. But today I can’t enter to my droplet. I use ssh root@<droplet_ip> and every time get Permission denied (publickey,gssapi-keyex,gssapi-with-mic). Even if I use ssh root@<droplet_ip> -i path/to/my/key it doesn’t work. I checked everything. I checked that ssh-add -L gets my public key and file on droplet /root/.ssh/authorized_keys (through browser Console access) has the same value. Seems everything is ok. But it doesn’t work now. I don’t know why. Maybe the problem on my side… but what exactly?

Same issue. It used to be successful at the first time. But then ends up the same issue.

Same issue. when trying with ssh root@ip_add, it says Permission denied (publickey).

have same problem , any news? i copy the pub key i generated via git bash then i did ssh root@etc but dosnt work… says same Permission denied (publickey) for root