Why My SSH Key won't work?

September 13, 2019 194 views
Security Ubuntu Getting Started DigitalOcean

So, I’ve set up quite a few SSH Keys, but my latest key doesn’t seem to be working. I’ve done what I’ve always done; copied the key directly from ~/.ssh/id_rsa.pub and pasted it into the Key(s) section on the Security Page in my DigitalOcean account panel.

This is the second key i’ve added, the first key still works. I’ve even tried restarting the service (even though I’ve never had to do that before).

I’m sure it’s my fault, something like I’ve just forgotten a simple step…

[USER]@[DROPLET-DOMAIN]; Permission denied (publickey).

1 comment
  • FYI - I supposed I’ll just add this manually. But maybe the web interface for adding keys only works on new droplets and subsequent keys will not be added to existing/running droplets/instances…

    I guess I just wanted to know why this wasn’t working for me…

2 Answers

Hi @TacticalDeveloper,

This error means the server actually reads the SSH key but finds some issues with it.

I’ll recommend checking THIS article on possible solutions.

Kind regards,
Kalin

You comment is correct, the key(s) installed on the droplet only happen on creation - adding new keys is not retroactive.

If you want to add the new key, you would add the private jey contents to your authorized_keys file, normally found here:

~/.ssh/authorized_keys

For root user, that is /root/.ssh/authorized_keys - it should already exist with the key it was assigned on creation. Copy the private key contents, the same that you pasted into the web cloud UI, and add them to the end of that file - then it should work.

Hope this helps and good luck!

Have another answer? Share your knowledge.