Prestashop logo, Visit home page

Configure your GitLab account

-

Reference documentation:https://docs.gitlab.com/ce/ssh/README.html

Git is a distributed version control system, which means you can work locally but also share or push your changes to other servers. Before you can push your changes to a GitLab server, you need a secure communication channel to share information. The SSH protocol provides this security and allows you to authenticate to the remote GitLab server without providing your username or password each time.

Don't use ssh2 format, use OpenSSH format instead.

 

Finding an Existing SSH Key Pair

Before generating a new SSH key pair, check if your system already has one in the default location by opening a shell, or Command Prompt on Windows (press Win + R ⇒ type "cmd" ⇒ press Press Enter), and executing the following command:

From a Command Prompt Windows :

type %userprofile%\\.ssh\\id_*.pub

From a GNU/Linux / Git Bash shell on Windows / macOS / PowerShell:

cat ~/.ssh/id_*.pub

If you see a string starting with ssh-rsa (or one of the formats below), you already have an SSH key pair and you can proceed to the next section without generating new keys and proceeding to the step of copy to clipboard. If you don't see the string or want to generate an SSH key pair with a custom name, continue to the next step.

Your SSH public key file may be named as follows:

  • id_rsa.pub : Key format ssh-rsa [key] [owner]
  • id_dsa.pub : Key format ssh-dss [key] [owner]
  • id_ecdsa.pub :Key format ecdsa-[algorithm]-[curve] [key] [owner]
  • id_ed25519.pub : Key format ssh-ed25519 [key] [owner]

Generating a new SSH key pair

For Windows users, install one of these apps:

  1. On a Windows command prompt, a Git Bash shell on Windows, a GNU/Linux shell, or a macOS shell, type the following command : ssh-keygen -t rsa -C "[email protected]" -b 4096

  2. Next, you will be asked to enter a file path to save your SSH key pair. If you don't already have an SSH key pair, use the suggested path by pressing Enter. Using the suggested path will normally allow your SSH client to automatically use the SSH key pair without additional configuration. If you already have an SSH key pair with the suggested file path, you will need to enter a new file path and declare for which host this SSH key pair will be used in your file .ssh/config.

  3. Once you enter a file path, you will be asked to enter a passphrase to secure your SSH key pair. It is recommended to use a passphrase for an SSH key pair, but it is not required and you can skip creating a passphrase by pressing Enter.

    If you want to change the passphrase of your SSH key pair, you can use ssh-keygen -p
  4. The next step is to copy the SSH public key, as we will need it later. To copy your SSH public key to the clipboard, use the appropriate code below:

    1. From a macOS shell : 
      pbcopy < ~/.ssh/id_rsa.pub
      
    2. From a GNU/Linux shell :
      xclip -sel clip < ~/.ssh/id_rsa.pub
    3. From a Windows Command Prompt :
      type %userprofile%\\.ssh\\id_rsa.pub | clip
      
    4. From a Git Bash shell on Windows or PowerShell : 
      cat ~/.ssh/id_rsa.pub | clip
  5. The final step is to add your SSH public key to GitLab. Go to the tab SSH Keys in your page Profile Settings.
    Hosting_gitlab.png
    Paste your key into the section Key and give him a pertinent Title. Use an identifiable title like Work Laptop - Windows 7 or Home MacBook Pro 15. . If you copied your SSH public key manually, make sure you copied the entire key starting with ssh-rsa and ending with your email address.

Test your setup

Open a Windows command prompt, GNU/Linux shell, or macOS shell and type the following command:

ssh -T [email protected]

If you receive a welcome message like Welcome to GitLab, @User!, then your configuration is working.

Share

Was the article helpful?