Connect to your DreamCompute Instance with SSH keys in Mac or Linux

Overview

You can connect to your DreamCompute instance over SSH using the instance's username and IP address.

Using Mac & Linux

First, create a key pair. You can create these within the DreamCompute dashboard, or on your local computer:

If you created the Key pair in the DreamCompute dashboard

If you created the Key pair in the dashboard, a .pem file was automatically downloaded to your computer. Move that file into your ~/.ssh/ directory.

For example, let's say you named the Key pair dashboardkey when creating it in the panel. A file named dashboardkey.pem was downloaded.

  1. Move the file from your /Downloads directory into your ~/.ssh directory:
    [local]$ mv ~/Downloads/dashboardkey.pem ~/.ssh
  2. Change the permissions to 600
    [local]$ chmod 600 ~/.ssh/dashboardkey.pem
  3. Run the following command to log in while specifying the file name:
    [local]$ ssh -i ~/.ssh/dashboardkey.pem USER@IP_ADDRESS

If you created the Key pair on your local computer

If you created the Key pair on your local computer, you now have a private and public key file in the ~/.ssh directory. For example:

[local]$ ls -la ~/.ssh
id_rsa
id_rsa.pub

You can now log in by running the following (make sure to change it to your IP address as shown above):

[local]$ ssh USER@IP_ADDRESS

What if I didn't name the Key pair id_rsa?

When you created the Key pair, you could name it anything you like. For example, let's say you named it dhc_key in step#1 by running the following:

[user@instance]$ ssh-keygen -t rsa
This creates a public/private keypair of the type (-t) rsa.
Generating a public/private rsa key pair.
Enter the file in which you wish to save they key 
(i.e., /home/username/.ssh/id_rsa):/home/username/.ssh/dhc_key/

You now must specify the name of the key while logging in. For example:

[user@instance]$ ssh -i ~/.ssh/dhc_key USER@IP_ADDRESS

How do I use a ~.ssh/config file to simplify logging in?

You can also create a 'config' file to simplify the ssh login process. For example, you can simplify your login to something like ssh dhc

Here is a full example of what a ~/.ssh/config file would look like. This example assumes the private key was downloaded from the panel as a .pem file and the username is 'ubuntu'.

Host dhc

HostName 208.113.167.187
User ubuntu
IdentityFile ~/.ssh/dashboardkey.pem
  1. Create a config file in your ~/.ssh directory.
  2. Edit the file to add the following:
    • Host: This is the shortcut name of your connection
    • HostName: This is the IP Address of your DreamCompute instance
    • User: This is the username of your DreamCompute instance
    • IdentityFile: This is necessary if your private key is named something other than id_rsa
  3. Run the following command to log into your instance.
    [user@instance]$ ssh dhc

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?