SSH on local Linux/MacOS workstation

If you would rather connect to your cluster using your own terminal on your machine, you must configure an SSH key in your Job settings prior to submitting your job. Instructions to for setting up your SSH key and connecting to your cluster can be found in the sections below.

Before connecting to the cluster, an existing public/private SSH keypair should exist or be newly created. The public key should then be added to your Rescale Account on the the Job Settings page. Please follow the steps given below depending on the type of workstation


Connecting from a Terminal

On Mac OSX and Linux, SSH key generation utilities can be run from the command line of a terminal. To open the Mac OSX Terminal, open the Finder and choose Utilities from the Go menu. Find the Terminal application in the Utilities window and double-click it. The Terminal window opens with the command line prompt displaying the name of your machine and your username.

First check for existing keys on your computer. From the command line of the terminal type:

$ ls -al ~/.ssh

This lists the files in your .ssh directory, however, if you have a new Mac OSX or Linux installation, the .ssh directory may not yet exist.

The default public key file names are:

  • id_dsa.pub
  • id_ecdsa.pub
  • id_ed25519.pub
  • id_rsa.pub

If you wish to use an existing key file for your Rescale account, you can skip to the next step - Copy contents of your public key

Generate a new SSH key

By default, keys for all identities are added to the directory:

  • /Users/_yourname_/.ssh on Mac OSX
  • /home/_yourname_/.ssh on Linux

If you have an existing identity (public/private key pair) in this directory that you want to use on Rescale, skip this step. To create a new default identity:

  1. Open a terminal session on your local system
  2. Enter ssh-keygen at the command line
  3. The command prompts you for a file to save the key in. If the .ssh directory doesn't exist, the system creates one for you
  4. Accept the default location

The ssh-keygen command creates your default identity with its public and private keys. The whole interaction will look like this:

[mairi@centos ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mairi/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mairi/.ssh/id_rsa.
Your public key has been saved in /home/mairi/.ssh/id_rsa.pub.
The key fingerprint is:
ed:88:95:91:38:e4:5e:ff:d6:73:70:f7:43:3e:f6:3b mairi@centos
The key's randomart image is:
+--[ RSA 2048]----+
|      .          |
|     o . .       |
|      + +        |
|     . o =       |
|      . S o   ..o|
|       o o . .ooo|
|      . . . o o=o|
|           .  .E+|
|               .+|
+-----------------+
  • You can, of course, save your new key pair to an alternative, i.e. non-default, location in your file system if you wish. By default, ssh-keygen generates 2048-bit RSA keys

  • ssh-keygen generates a public key and a private key. If not specified, the default public key will be saved as id_rsa.pub and the private key as id_rsa in your ~/ssh folder. Ensure that the ~/ssh is only accessible by you by setting the proper permissions to that folder:

    chmod 700 ~/.ssh
  • On Linux, copy the contents of your chosen public key file by opening it in a text editor or by running the cat command (in this case the public key is stored in the id_rsa.pub file):
$ cat ~/.ssh/id_rsa.pub
  • On Mac OSX, you can use the command pbcopy in the terminal to copy the contents of your public key file to the clipboard as follows:
$ pbcopy < ~/.ssh/id_rsa.pub
  • On your Rescale platform account page, click on the <user>@rescale.com button at the top right corner
  • Select Account in the drop-down menu
  • Click on Job Settings option on the left side of the page

AccessJobSettings.png

  • Once you have copied the contents of your public key, paste the contents of the public key into the SSH Public Key field. Click Save and you are able to SSH into all your future clusters

  • The Access Restriction (CIDR range) field allows you to select which IP addresses can access your cluster. The options Everywhere or My Current IP Address can be set automatically from the pull-down menu. You can also specify your own custom Classless Inter-Domain Routing (CIDR) range rule by editing the Access Restriction (CIDR range) text field directly


In Mac OSX and Linux, you can use the terminal to log into your machine.

When you provision a cluster, the Job Logs window on the Status tab will display a message showing the job's username on the system and the public IP address of the master node of the cluster. The message will look like this:

job-logs.png

In this example, the job username is uprod_qpWia and the public IP address is 107.23.132.81. You will need this information to log in to the cluster.

  • To log in to the cluster from a Terminal window, call ssh using a command of the form:
$ ssh -i ~/.ssh/<private key file> uprod_qpWia@107.23.132.81
  • Here, <private key file> corresponds to the previously generated private key, id_rsa (Not id_rsa.pub)
  • If your privatekey file in an alternative directory, substitute the correct file path after the -i flag
  • The ssh command will log you in to your machine as the job user. If you defined a passphrase for your SSH key, the operating system will prompt you for it.

The terminal prompt should now show that you have logged in as the job user