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-keygenstep.
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 ed25519In this example, we select the more modern
ed25519key instead ofRSA. But anRSAkey 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.pubNow, 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"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.
Sign in to the official EPFL GitLab: gitlab.epfl.ch
Go to: Your profile icon (on the left) ->
Preferences -> SSH Keys (left) ->
Add new key (top right)
Paste your public key and add it to GitLab.
Example: Adding a new ssh key to 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@nothttps://).Example:
git clone git@gitlab.epfl.ch:gnugen/just-do-git-lab.git