I restored my Droplet to a fresh one with Ubuntu (I’m using 19.10 but it’s not on the Topic list) however I can still access with my old SSH key. Is it possible to replace the root key for a new one?
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.
Hello, @JuanDssCarp
You can change the key by simply accessing your droplet and edit the authorized keys file in
/root/.ssh/authorized_keys
You can remove the old key and paste your new one and then save the file.
Let me know how it goes.
Regards, Alex
I’m relatively new, so there’s probably better/more elegant solutions somewhere, but here’s my best guess.
Do you still have the .pub file from when you created the SSH key you no longer want? If so, and if you can view the contents, have that available.
Then, SSH into the server and type:
cd ~/.ssh
In that folder, you should have a file called authorized_keys
Use your favorite editor to remove the SSH key that matches the .pub file you have open.
I just tried it on a droplet that I spun up, and it seemed to work. When I tried SSHing in with the key that I deleted, I got the “Permission denied (publickey).” error.
Please reply if this works for you. If so it’ll be my first answer on the forum here!
EDIT: I totally misread your question. You wanted to replace the SSH key, not just remove the old key.
So the same basic principle applies: You need to edit the authorized_keys file with the SSH keys that you want to log in. So the only additional step is to, while you are logged into the server and editing the authorized_keys file, paste in the contents of the .pub file for your new SSH key.
Again, please reply whether this helps or not.