Hi, my name is David Carr and I'm a PHP Developer.

Blog Archives Categories Authors About Me Open Source Books Contact Me

Sponsor Me

Help support the blog so that I can continue creating new content!

My Latest Book

Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Digital Ocean - Add SSH key to droplet after creation

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/id_rsa.pub

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 id_rsa.pub.

touch /home/username/.ssh/authorized_keys


Copyright © 2009 - 2022 David Carr. All code MIT license. All rights reserved.