This is an old revision of the document!
Table of Contents
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 certificate 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, you can proceed to step 2. 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"
To generate the key via PuTTygen follow the guidelines of the product.
Remember that you can also use another name for the file name. You can call the file gitlab_rsa if you prefer or anything else.
CONFIGURE GITLAB ONLINE
Login to GitLab and go to → Profile Settings → SSH Keys. In the field Key copy the contents of the file: id_rsa.pub generated in step 1. Once you click Add Key, you will see the key listed in your SSH Keys.
LOCAL GITLAB PROFILE
You have to configure your locally installed gitlab to connect using the ssh key.
LINUX/MACOSX Inside a terminal, type the following: git config –global user.name “Firstname Lastname” git config –global user.email “your_email@unibz.it” git config –list
WINDOWS Inside your GIT bash command line, 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.
You have to edit your gitlab configuration to reflect the URL and the username/email to use when connecting. To do so
1. edit the file ~/.gitconfig and insert your data:
[user] name = Lastname Firstname email = your_email@unibz.it
2. edit .ssh/config
host gitlabhostname.unibz.it user your_username