User Tools

Site Tools


How to add an SSH Key for GITLAB


You need an SSH key that resides on your workstation/notebook. You can use an already existing key or generate a new one.

To check if you already have an SSH key you have to check the file:





If this file contains an SSH-RSA key (open the file with a text editor), proceed to Configure the SSH key on

If this file is empty or does not exist, it means that the key was never generated so you have to generate it.

To generate an SSH key via command line open a LINUX/MACOSX terminal or WINDOWS Git BASH and run the command:

ssh-keygen -t rsa -C "your@email" -b 4096

When you're asked to “Enter a file in which to save the key,” select either the default location or a location you prefer and leave as name id_rsa (if this is your only RSA key) or setup a file name of your choice.GitLab Official Documentation

Windows Git Bash your rsa-key (~/.ssh/id_rsa) file MUST be called id_rsa.

You can also use a key generator such as PuTTYgen instead of using the terminal. Please refer to the guidelines of the product on how to create the RSA key and the location of the file.


Login to GitLab and go to your profile → Settings → SSH Keys.

In the field Key copy all the contents of the file: (or the specific name of your RSA key)

Choose a name to identify the key (ex. YourComputerName)

Click Add Key.

The key is listed in your SSH Keys.

Official Gitlab Documentation



You have to configure your locally installed gitlab client to connect using the ssh key.

Inside a terminal (Linux, MacOS)/Git BASH (Windows), type the following:

git config --global "Firstname Lastname"
git config --global "your@email"
git config --list

The last command should show the data you entered and is your gitlab global configuration.

This data is saved in the file ~/.gitconfig:

        name = Lastname Firstname
        email = your@email

Try to checkout repo. Should you experience trouble check the contents of file: .ssh/config. You can manually insert:



You can also have different git accounts (with different RSA keys) for different hosts. You can keep a global user/email configuration and a local configuration for a specific repository. In the root of a repository, run:

git config "Firstname Lastname"
git config "your_other@email"
/var/www/ · Last modified: 2019/12/03 14:18 by apano