User Tools

Site Tools


auth:howto:sshkeygitlab

This is an old revision of the document!


How to add an SSH Key for GITLAB

GET/SET SSH KEY

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 certificate that you have to check the file: LINUX/MACOSX

.ssh/id_rsa.pub 

WINDOWS

%userprofile%\.ssh\id_rsa.pub

If this file contains an SSH-RSA key, proceed to Configure the SSH key on gitlab.inf.unibz.it. If this file is empty or does not exist, it means that the key was never generated.

To generate the key you can use a key generator such as PuTTYgen, or command line. To generate the key via command line use the command:

ssh-keygen -t rsa -C "your_email@unibz.it" -b 4096

To generate the key via PuTTygen follow the guidelines of the product.

Windows GitBash your rsa-key file must be called id_rsa. Create it if it does not exist and add the generated rsa key there

Remember that you can also use another name for the file name. You can call the file gitlab.inf_rsa if you prefer or anything else. GitLab Official Documentation

CONFIGURE GITLAB ONLINE

Login to GitLab and go to → Profile Settings → SSH Keys.

In the field Key copy all the contents of the file: id_rsa.pub (or the specific name of your RSA key) Click Add Key.

The key is listed in your SSH Keys.

Official Gitlab Documentation

GITLAB CLIENT CONFIGURATION

GLOBAL GIT ACCOUNT

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 user.name "Firstname Lastname"
git config --global user.email "your_email@unibz.it"
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:

[user]
        name = Lastname Firstname
        email = your_email@unibz.it

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

host gitlabhostname.unibz.it

LOCAL GIT ACCOUNT

You can also have different gitlab 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 user.name "Firstname Lastname"
git config user.email "your_other@email"
/data/www/wiki.inf.unibz.it/data/attic/auth/howto/sshkeygitlab.1497351139.txt.gz · Last modified: 2019/01/16 10:03 (external edit)