This article details the process of adding an SSH Key from your Remote Development Server to GitLab.


Prerequisites

To follow along with this guide, you'll require:

  • A GitLab Account
  • A Remote Development Server (to make your own, check out our article)

Configure GitLab SSH Key

On your Remote Development Server, navigate to /home/<username>/.ssh and create a directory for GitLab:

mkdir gitlab

Change into the directory we created:

cd gitlab

Now it's time for us to generate a new SSH Key:

ssh-keygen -f /home/<username>/.ssh/gitlab/id_rsa

There is no requirement to enter a password for the SSH Key. Enter down twice to skip the password creation prompt.

After the key has been generated, open the file id_rsa.pub file and copy the key.

nano id_rsa.pub

Navigate to your GitLab Account Settings. Select SSH Keys from the menu on the left hand side.

Enter the contents of the key in the relevant field and give the SSH Key a name.

There is no requirement to set an expiry date on the SSH Key. Feel free to leave it blank when adding the key. Setting an expiry date can be useful if you are sharing SSH Keys with colleagues or are consistently swapping between devices that are also used by others.

Add the key and test that you are able to clone one of your repositories. If you are able to successfully clone your repository, you have correctly setup the SSH Key.


Running into issues?

Reach out to us by using our Contact Form on devdemand.co, leave a comment below, or find us in most of the Open Source Infrastructure Slack Groups like CNCF and Kubernetes!