How To Use SSH Key With DigitalOcean Droplet

Create SSH Keys. You shall be prompted for a passphrase (I would recommend putting in a passphrase, at least it would still be secure if someone get hold of your SSH Keys).

ssh-keygen -t rsa -f [FILENAME] -C "[NAME]"mv [FILENAME] [FILENAME].pem

Now you would have 2 files:

  • [FILENAME].pem
  • [FILENAME].pub

When created a new droplet, at the Add you SSH keys section, click New SSH Key. Copy the content of [FILENAME].pub into SSH key content and enter a Name.

cat [FILENAME].pub

DigitalOcean SSH

After a droplet is created, you can ssh into the server using the following command.

ssh -i [FILENAME].pem [email protected][SERVER_IP_OR_DOMAIN_NAME]

Note: remember to backup and secure the .pem file and remember the passphrase.

Note: I prefer to use the above method to store my SSH keys in my own directory (for proper file naming and backup). You can also follow this tutorial which store SSH keys at default .ssh directory.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.