Chapter 2. SSH Key Setup

Overview

Before you can clone a git repo, you must first upload your SSH public key (for more information on Public-key cryptography, check out this Wikipedia article).

This tutorial will show you how to generate a public/private key pair (if required) and upload the SSH Public Key to the Platform via FHC.

Requirements

You should install FHC before completing this tutorial.

2.1. Checking for an existing SSH Public Key

To check if an SSH public key has been generated, open Terminal on Linux or Mac, or Git Bash on Windows.

Run ls -la ~/.ssh

This will list the files in the .ssh directory. If you see files named either id_rsa.pub or id_dsa.pub, then the key has been generated and you can skip to Adding an SSH Public Key to the Platform via FHC. If you do not see either of these files, then proceed to Generating an SSH Public Key, as you must generate an SSH public key manually.

2.2. Generating an SSH Public Key

In order to generate a key, we will use a tool called ssh-keygen. Open Terminal on Linux or Mac, or Git Bash on Windows.

Enter the following:

ssh-keygen -t rsa -C "your_email_address@example.com"

After you have entered this command you will be asked where to save the key. Press the enter key to use the default location.

You will then be prompted to enter and confirm a password for the private key. When complete, the public & private key should be written to ~/.ssh/id_rsa.pub & ~/.ssh/id_rsa.

2.3. Adding an SSH Public Key to the Platform via FHC

Using FHC, log in to the Platform. When adding a public key, you must specify both a name and a key file. To add a key, enter the following command:

fhc keys ssh add <label> <key-file>

For example:

fhc keys ssh add myKey ~/.ssh/id_rsa.pub

You can verify that the key has been added correctly by listing out all ssh keys for the user.

fhc keys ssh

You should now be able to see your recently added key.

Note

If you need to use multiple SSH keys, follow our guide for configuring your local SSH to use multiple keys.

2.4. Adding an SSH Public Key to the Platform via Studio

Follow these steps to add your public SSH key to the Platform using the Studio:

  1. Log into the Studio.
  2. Click on the portrait button located on the top right of the screen.
  3. Select Settings.
  4. Select SSH Key Management. A list of previously uploaded SSH Keys will be displayed.
  5. Select Add New Key.
  6. Paste your public key into the Public Key field.
  7. Select Upload Public Key.

You should now be able to see your recently added key in the list of keys.