SSH error - Permission denied (public key).

February 3, 2017 4.2k views
Getting Started Quickstart Ubuntu

I followed this to try to add authorized keys to my droplet. I ended up loosing permissions in my starting machine and not being able to log in from the second machine either.

I could not type '~' in the web console, so i am not able to authorize more keys either.

What can i do to overcome the: "Permission denied (public key)." error?

3 Answers

@tiagobertolo

When logged in as root, /root/.ssh is equal to ~/.ssh, so if for one reason or another, you're unable to use ~, then /root/.ssh will work as a direct path.

In regards to /root/.ssh/authorized_keys, these are the public keys for the root user that are allowed to login. So if you're attempting to login to SSH using a command such as:

ssh root@DROPLET_IP -i /path/to/private_key

... then private_key needs to be associated with one of the public keys in authorized_keys on your Droplet, else authentication will fail.

What are the authorized keys? The ones present in the ~/.ssh/authorized_keys file or the ones in the profile settings of my digital ocean account?

By logging in again i was able to chmod 600 my ~/.ssh/authorized_keys and paste there my public key. It still does not work.

PS: Can't edit my question. How nice.

Did you check /var/log/auth.log?

Have another answer? Share your knowledge.