Can not ssh to my newly created droplet

I just created a ubuntu 18.04 LTS droplet with SSH connection. I am trying to access it from my terminal at local machine by ssh <PUBLIC IP>. but I am getting Permission Denied (public key). I have added the SSH key from id_rsa to my DO account and also added it to the droplet when creating. I did not set any password as I wanted to do via SSH only. When I am trying to access console from the dashboard, it’s asking for password which I did not set. How can I solve this?

I tried to destroy and recreate droplet, but same problem is occurring. How can I fix it?

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Site Moderator
Site Moderator badge
July 28, 2019
Accepted Answer

You need to add your key to your DigitalOcean account. Also when you ssh you can use the -vvv option to get more verbose output and see why it fails to connect, e.g

ssh -vvv root@IPAddress

If the ssh is still failing, feel free to paste the output of the ssh connection.


In case someone else has this issue in the future… recreating the droplet for me was not an option as I already had updated DNS to point to the IP address assigned to the droplet.

Make sure when you copy the contents of your key and paste it into the DigitalOcean SSH key add form, you don’t have any spaces or newlines following the last character of the key. Whitespace/newlines will cause the key to be invalid and the connection to fail. That was my issue. I deleted the bad SSH key at DigitalOcean and created a new one, this time making sure no spaces (or newlines) followed the last character of the key (which is usually your local username or email address).

Hope that helps someone in the future!

I experienced the same issue even though I had added my SSH key when I created the droplet. I ended up resetting the password which resulted in the SSH key working again without doing anything else. NB. ssh -vvv user@myip showed me that the SSH key was in known_hosts but for some wierd reason it was not authenticating me. I think @lakeshore 's answer is very useful as well

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel