Skip to content

Latest commit

 

History

History
76 lines (51 loc) · 2.19 KB

gitlab.md

File metadata and controls

76 lines (51 loc) · 2.19 KB

Gitlab

Add gitlab ssh key

We use the ssh protocol to clone project from Gitlab. This is a step-by-step guide on how to setup your ssh key on gitlab account. You can also check the gitlab doc here.

Generate an SSH key pair

ssh-keygen -t ed25519 -C "<email>"

Press Enter. Output similar to the following is displayed:

Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519):

Accept the suggested filename and directory unless want to save in a specific directory.

Specify a passphrase:

Passphrase is not asked on git clone, so you can fill it

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

If you already have an ssh key, and you wish to test your passphrase you can run the following command:

ssh-keygen -y -f ~/.ssh/id_ed25519

A public and private key are generated. Next, add the public SSH key to your GitLab account.

Add an SSH key to your GitLab account

  1. Copy your public key to your GitLab account

require the xclip package (sudo apt install xclip)

xclip -sel clip < ~/.ssh/id_ed25519.pub

Now, your public key is on your clipboard.

  1. Add to your GitLab account
  • Go on gitlab > avatar > Edit profile > SSH Keys > Add new key
  • In the Key box, paste the contents of your public key. Must be start with ssh-ed25519.
  • In the Title box, type a description, like "Work Laptop" or "Home Workstation".
  • Select the Usage type Authentication & Signing
  • Remove Expiration date
  • Select Add key

Verify that you can connect

Open a terminal and run this command, replacing gitlab.example.com with your GitLab instance URL:

For retrieve your gitlab instance url : go to see project clone ssh url and take first part before : ex : git@gitlab.com

ssh -T git@gitlab.example.com

If this is the first time you connect, you should verify the authenticity of the GitLab host and re-run the previous command

You can troubleshoot by running ssh in verbose mode

ssh -Tvvv git@gitlab.example.com