How do i add an ssh key to an existing droplet?

  • Posted November 22, 2014


I have been trying to add a public key on a pre-existing droplet and I am not able to connect although I have tried to paste it on the original SSH KEY, and on a new key. I have followed this tutorial, but it is not really showing it well on how i can get into a preconfigured drop-let.

Thank you


You probably want to ssh in as root and not a specific user as you might be doing it for the first time and have not created a user yet.

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.

You can add an ssh key to an existing droplet by appending the public key (ssh-rsa ...) to /home/user/.ssh/authorized_keys or /root/.ssh/authorized_keys.

If you’re on Linux, you can run the following command to do that automatically:

ssh-copy-id user@

On OSX, you can run this command instead:

cat ~/.ssh/ | ssh user@ "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

I got it to work by adding the ssh key to both /root/.ssh/authorized_keys and /root/.ssh known_hosts then restarting the droplet

The following have worked for me:

  1. Create GitHub repo and put your key in it
  2. Clone the repo using console
  3. Run cat /path/to/cloned/github/project/key | cat >> ~/.ssh/authorized_keys

NB key is a file containing the value

**Tip: **

If you have forgotten root password then you need to reset the root password.

Just in case you cannot login as root from your computer console, you need to enable root login.

nano /etc/ssh/sshd_config then PermitRootLogin yes and restart ssh service ssh restart.

then proceed as above.

Don’t forget to change PermitRootLogin without-password and restart ssh service service ssh restart or just kill the process ps auxw | grep ssh.

**TIP2: **

If you are using a different ssh key other than then modify your ~/.ssh/config file.

Unable to edit my previous post. According to support it is the public key that is entered into the “Add SSH Key” field when creating a new droplet. The respond further, writing, “The [control panel] console does not allow you to use SSH keys. These can only be used for [connecting with SSH via PuTTY or other appropriate client]. The console on your control panel is a VNC style connection intended to be used when you cannot connect via SSH. It can only be used with passwords.” As you see, I edited their text somewhat for clarity.

btw, i dont sure if my message sent…

i followed this steps and add ssh key to my existing droplet as you say, and now can login with user@ip_address without password. but when i trying to login as root@ip_adress or on other computer as user@ip_adress and root@ip_address, it still asking password except automatically kicking out without being prompted for a password. whats the problem?

This comment has been deleted