Skip to content

Gitlab and SSH Keys

GitLab uses the SSH protocol to securely communicate with Git.

When you use SSH keys to authenticate to the GitLab remote server, you don't need to supply your username and password each time.

Add an SSH key to your account

To use Gitlab with SSH, you will need to register your SSH key to your Gitlab account by following the next steps:

  1. Verify if you have an existing key in your system. If not, generate one.

  2. Add the SSH key to your Gitlab account.

Configuring Username and Email

  1. Open a terminal and run the below commands.
    git config --global <YOUR USERNAME>
    git config --global <YOUR EMAILID>

Test the connection

  1. Open a terminal and run this command.

    ssh -T
  2. If this is the first time you connect, you should verify the authenticity of the GitLab host. If you see a message like:

    The authenticity of host ' (' can't be established. ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw. 
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '' (ECDSA) to the list of known hosts.

    Type yes and press enter.

  3. Run the ssh -T command again. You should receive a Welcome to GitLab, @username! message.