DOCS
clock Last Modified: Nov 13, 2018

How to configure your SSH Keys

Last modified: November 13, 2018

A step-by-step tutorial on how to generate and set up your SSH Keys in the Presslabs dashboard in order to easily access your site’s source code via the SSH Protocol.

A common transport protocol for Git is SSH, which provides secure access to remote servers, in this case our git servers stack. This protocol consists of a SSH key pair, which includes a public key and a private key.

In order to be able to clone your code locally using the SSH url we provide, you need to generate a SSH key pair, and introduce the public key in the Presslabs dashboard.

Step 1. Create a SSH key pair

A SSH key pair consists in a public key and a private key. You need to add the public key in the Presslabs dashboard and store carefully the private key and not share it with anyone.

1. On Linux and MacOS

In order to create a SSH key pair on Linux or macOS, you need to use the ssh-keygen command. Simply open the terminal and run:

ssh-keygen

This command will require you to fill the next fields:

  • Enter the file name where you want to save the key (/home/<user_name>/.ssh/id_rsa) This means that if you leave this field empty and simply press ENTER, it will save the private key as id_rsa and the public key as id_rsa.pub in the /home/<user_name>/.ssh/ directory.
  • Enter passphrase (empty for no passphrase)
  • Enter same passphrase again

Now, in the .ssh directory you will have the two keys created. Unless you changed their names, the public key is id_rsa.pub and the private one is id_rsa.

Display the public key in the command line so you can copy it:

cat ~/.ssh/id_rsa.pub

An example of a public key can be seen below.

Commands for generating a SSH key pair on macOS
info Commands for generating a SSH key pair on macOS

2. On Windows

Generate a SSH key pair from Git Bash

Git for Windows focuses on offering a lightweight, native set of tools that bring the full feature set of Git SCM to Windows while providing appropriate user interfaces for experienced Git users and novices alike.

It comes with a BASH emulation used to run Git from the command line, as well as a Git GUI. The installation is simple and straightforward.

This way, simply open the Git BASH command line and follow exactly the same steps as for Linux and macOS operating systems, using ssh-keygen.

Commands for generating a SSH key pair on Windows using Git Bash
info Commands for generating a SSH key pair on Windows using Git Bash

Generate SSH key pair using PuTTYgen

PuTTYgen is a SSH keys generator tool for PuTTY, resembling the ssh-keygen from linux and macOS. PuTTYgen is normally installed as part of the normal PuTTY package installation, which you can install from here.

After installing PUTTYgen, go to Windows Start menu → All Programs → PuTTY→ PuTTYgen to start it.

In order to generate a SSH Key Pair, simply press the Generate button, then move your mouse in order to generate some randomness.

The Putty Interface
info The Putty Interface

You need to save your private key and store it in the /home/<user_name>/.ssh/ directory, along with your public key. You need to copy the public key shown here, and introduce it in the Presslabs dashboard as shown at Step 2.

The generated SSH key pair
info The generated SSH key pair

Step 2. Add your public key to our dashboard

You need to upload the public key in our Dashboard in the SSH Keys Section. The private key needs to be stored and handled carefully, and no copies of the private key should be distributed.

Go to https://o.presslabs.com/#/account/ssh-keys, as seen below.

Here you need to fill in the blanks:

  • Label: set a label for your key
  • Public Key: paste the public key copied from the terminal.
Introducing your public key in the Presslabs dashboard
info Introducing your public key in the Presslabs dashboard

Step 3. Clone your code locally

Now you can clone your code locally. The clone URL can be found in the Access section in the dashboard:

git clone git@git.presslabs.net:user/mysite.git
cd mysite
git checkout master
The Access section from the Presslabs dashboard
info The Access section from the Presslabs dashboard

FAQ

Can I use ssh-keygen on windows?

Yes, you can generate a SSH key pair on Windows operating systems using ssh-keygen if you install Git for Windows, check Generate a SSH key pair from Git Bash.