Digital Ocean | VPS | Tutorials

David Carr

Digital Ocean - Add SSH key to droplet after creation

When creating a droplet you can add an SSH key during setup, later if your key changes you won’t be able to SSH into the server.

The advice is to login to the droplet and add the SSH key to:


I found trying to copy and paste the key difficult.

Another approach is to turn on password authentication by editing sshd_config.

vi /etc/ssh/sshd_config

Change PasswordAuthentication from "no" to "yes".

Restart the server.

service sshd restart

Exit the server.

From your computer, copy the ssh key.

cat ~/.ssh/

Now ssh in from your computer.

ssh root@ip

Enter the password

Paste the ssh key.


You will now be able to login without using the password, at this point you can turn PasswordAuthentication from yes to no to disable password authentication inside

vi /etc/ssh/sshd_config

Restart the server.

service sshd restart

To add a SSH key to a user, add a .ssh folder.

mkdir -p /home/username/.ssh

Make authorized_keys file and add the

touch /home/username/.ssh/authorized_keys


Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.