How to use SSH keys to access Digital Ocean droplet

15 December 2014

Digital Ocean is a really wonderful place to host your applications. In this post I will show you how to generate and configure SSH key for your newly created droplet.

1. Background

The reason why this may be important to you is that ssh protocol is used to synchronize files between your workstation and your server. If you plan to use:

to copy files to your Digital Ocean droplet you should start with setting up your ssh keys.

2. Generate a new SSH key

Open your shell and create a new ssh key:

$ ssh-keygen -t rsa -C "" -f developer

You will be asked for a passphrase. To make the things easier you can use empty passphrase. Just press Enter key twice.

The command will create two files:


Move these files to your .ssh/ directory.

$ mv developer* ~/.ssh

3. Add the SSH key to your Digital Ocean account

Log in to your Digital Ocean account and upload the key stored in using SSH keys/Add SSH Key button.

4. Create a new droplet

During creation of a new droplet remember about adding your developer key to the list of authorized keys.

5. Update your .ssh/config

Open your SSH configuration file with vi:

$ vi ~/.ssh/config

Then enter the configuration for your droplet hosted by Digital Ocean:

Host DigitalOcean
  User root
  IdentityFile  ~/.ssh/developer

The IP comes from your droplet properties page.

6. Verify your ssh access

Run the command:

$ ssh DigitalOcean

It should start a new ssh session to your droplet.

7. Reading list

  1. Github Help: Generating SSH keys
  2. Github Help: Working with SSH key passphrases
  3. Stackoverflow: Multiple GitHub Accounts & SSH Config
  4. nixCraft: OpenSSH Config File Examples
Fork me on GitHub