Connect to your instance with SSH keys in Mac or Linux

To log in, you'll need your User and IP Address of the instance.

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 that from your /Downloads directory into your ~/.ssh directory:
    macbook$ mv ~/Downloads/dashboardkey.pem ~/.ssh
  2. Change the permissions to 600
    macbook$ chmod 600 ~/.ssh/dashboardkey.pem
  3. You can now log in while specifying that file name:
    macbook$ 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:

macbook$ 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):

macbook$ 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:

[server]$ 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:

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

Using 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.

  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. 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
  4. You can now log into your server instance with the following command
    [server]$ ssh dhc

Did this article answer your questions?

Article last updated .