I changed my public and private keys on Terminal (I’m using Mac OS) many times. So when I “ssh” into the IP address given to me by my Droplet (the IP address is 107.170.60.7
), I get the error of Permission denied (publickey)
. so I know it has to do with me changing the public/private key. So now I need to add that changed public key on my Terminal to my Droplet on DigitalOcean. There were two things suggested by the DigitalOcean community which I’ve tried:
The tutorial on here - but this is for Windows users, not Mac. It’s suggests using a “Search and Replace” and checking certain functionalities. But Macs don’t have this so I can’t even use it: http://geektnt.com/how-to-add-ssh-key-to-existing-digitalocean-droplet.html
A user kept suggesting to someone else that the problem is resolved by visiting this page: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2 I read into it and it has everything to do with setting up a SSH key, which I already know, and NOTHING to do with how to ADD an ssh key to an existing Droplet.
I really just need to know how to add my changed ssh key to my Droplet. I would really appreciate the help if anybody knows.
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!
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.
Since the last post on this topic there have been new Docs.
As such for anyone stumbling upon this, please check this docs page and read upon the process:
https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/
@confused5000
To add an SSH Key to your Droplet, you’ll need to be able to access it. Do you still have the old key that you were using? If so, SSH in to your Droplet using the old key and add your new public keys to:
The format is one key per line. You can remove the old key from this file.
If you don’t have the old key that you were using, you may very well be locked out as console access to the Droplet is limited to password-based authentication.
@confused5000
To SSH in with a key, you have to pass the
-i
flag and define the full path. So if your key name was:On MacOS, you’d use:
That being said, if you created a Droplet with one key and then overwrote it, you’ve effectively locked yourself out. The only way to get around this would be if you set a password for
root
, then you could try to login without it, but seeing as you’re getting:… when trying to login with
ssh root@107.170.60.7
, that tells me that you don’t / didn’t.