Question

Can't access droplet any more after adding a new SSH key

I initially created a droplet and added my SSH key in the creation process. It worked well, I could easily connect to server from my local machine via SSH. However, I recently had to reinstall my OS and lost my saved ssh key, so have had to create a new ssh key. I can’t get it to work. I have tried the commands and get these error messages:
C:\ $ ssh root@droplet IP root@droplet IP: Permission denied (publickey).

C:\ $ ssh -i ~/.ssh/id_rsa root@droplet IP root@droplet IP: Permission denied (publickey).

Also, I have deleted my original ssh key from my digitalocean droplet account to try and resolve this but that has not helped.

Subscribe
Share

Submit an 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.

Hi @sub359,

It seems like you are trying to use your private id_rsa key to enter. In order to enter using your SSH key, you’ll need to do the following.

  1. Copy your public ssh key in the file id_rsa.pub.

  2. SSH into your droplet’s console and your root password from your Contron Panel

  3. Paste the id_rsa.pub contents in your ~/.ssh/authorozied_keys

  4. Restart your sshd service service sshd restart

  5. Give it another go to SSH to your droplet.

Regards, KDSys