Add ssh key to existing droplet in digital ocean

11,280

Solution 1

You can reset root password at digital ocean's website.

This function appear at your droplet's "Access" tab.

And you can follow this article to get access to your droplet using ssh-key

https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-putty-on-digitalocean-droplets-windows-users

Solution 2

I registered few of the SSH keys for different PCs, so my method is that

1.) Use another pc to login eg.bash (ssh root@yourDropletIP)
2.) Go to your .ssh folder (/.ssh)
3.) Use nano or other text editor to open (nano .ssh/authorized_keys)
4.) Added your new machine ssh-keys to end of the file (notice: check is any empty space between keys, if so, delete it.
5.) Use your new machine to log in and enjoy!!!

Solution 3

I have to hack around this process.

  1. Copy your existing SSH key from local machine to a keys.txt file and push to Github.

pbcopy < ~/.ssh/id_rsa.pub

  1. Clone the file to Digital Ocean server and copy to authorized_keys.

cat keys.txt > authorized_keys

Solution 4

This may be useful for anyone else who is using Windows with PuTTY.

  1. Change the sshd_config file - set the PasswordAuthentication entry to yes, restart sshd, then login to the droplet via PuTTY.

  2. Copy your public ssh key to the clipboard in Windows. In the PuTTY console, paste the key into the authorized_keys file with a text editor (nano).

  3. Go back into the sshd_config and set PasswordAuthentication back to no.

  4. Restart sshd, logout. Login via PuTTY without a password.

References:

  1. https://www.digitalocean.com/community/tutorials/how-to-use-ssh-keys-with-putty-on-digitalocean-droplets-windows-users

  2. https://www.digitalocean.com/community/tutorials/how-to-create-ssh-keys-with-putty-to-connect-to-a-vps

Share:
11,280
Tejashri Bedarkar
Author by

Tejashri Bedarkar

Updated on July 02, 2022

Comments

  • Tejashri Bedarkar
    Tejashri Bedarkar almost 2 years

    I have the droplet on the digital ocean. I have tried to add ssh key to existing droplet. But there they asked for root password and I don't have root password. I have tried to connect to the droplet through the putty. It is giving message : Unable to use key "home/id_rsa" (OpenSSH SSH-2 private key). How to connect to droplet using ssh key? And What is the proper way to connect to the droplet? Is there any way to add ssh key to the existing droplet?