GitLab Setup

Setup Access to GitLab

Local configuration

You need to have git installed:

In order for you to access a Git remote (like the EPFL GitLab), GitLab needs to validate that it is in fact you that is connecting to your repository.

The authentication is done via public key cryptography, which means we have to generate a private key (that only we know) and a public key (which we can give to GitLab).

If you are asked if you want to overwrite the key, select no. As a key already exists, we don’t want to overwrite it, skip the ssh-keygen step.

Generate a new key with the following command and follow the prompt (keep the name as ~/.ssh/id_ed25519 as suggested by the prompt):

ssh-keygen -t ed25519

In this example, we select the more modern ed25519 key instead of RSA. But an RSA key is totally fine too. Optional: Click here if you want to learn why.

Let’s view the public key that we will later use for GitLab:

cat ~/.ssh/id_ed25519.pub

Now, set your email and username for GitLab. Replace the variables written with caps lock with your real email and name and enter the command:

git config --global user.name "FIRSTNAME LASTNAME"
git config --global user.email "FIRSTNAME.LASTNAME@epfl.ch"

Configuration on GitLab

We have now created a key locally, but the GitLab doesn’t yet know that.

The public key we generated has to be added to GitLab.

  1. Sign in to the official EPFL GitLab: gitlab.epfl.ch

  2. Go to: Your profile icon (on the left) -> Preferences -> SSH Keys (left) -> Add new key (top right)

  3. Paste your public key and add it to GitLab.

Example: Adding a new ssh key to GitLab

Use GitLab!

If you now clone your project using git, it automatically uses your key for authentication 🎉

Make sure to use the SSH syntax for cloning (with git@ not https://).

Example: git clone git@gitlab.epfl.ch:gnugen/just-do-git-lab.git