Git

How to Add and Configure SSH Key on GitLab

GitLab remote server uses the SSH protocol to securely interact with Git. The SSH is known as “Secure Socket Shell” or “Secure Shell” that is utilized for managing the operating system, and networks. It is also used for authentication and configuration to the GitLab server without specifying the username and password each time.

In this guide, we will illustrate adding and configuring SSH keys on GitLab.

How to Add and Configure SSH Key on GitLab?

Follow the provided steps to add and configure the SSH key on GitLab:

    • Open the “Edit Profile” settings.
    • Access the “SSH Key” settings.
    • Add the public key in the given fields and specify its title.
    • Click on the “Add key” button.
    • Connect with the GitLab account by running the “ssh -T [email protected]” command.

Step 1: Open Edit Profile Settings

Initially, switch to GitLab, click on the profile icon, and select the “Edit profile” option from the drop-down menu:


Step 2: Access SSH Keys Tab

Next, hit the “SSH keys” option inside the User Settings“ left-side menu:


Step 3: Add Public Key

Then, copy the public key from where it is saved and paste it into the below-provided “Key“ fields. After that, add the “Title”, “Usage type”, and “Expiration date”. Then, hit the “Add key” button:


As you can see, the key has been added successfully. You can delete it by clicking on the “Delete” button at any time:


Step 4: Check SSH Key Working

Lastly, open the Git utility and execute the provided command to connect with the GitLab account:

ssh -T git@gitlab.com

 
The below-given output indicates that we have successfully connected with our GitLab account:


We have explained the way of adding and configuring SSH keys on GitLab.

Conclusion

To add and configure the SSH key on GitLab, first, access the “Edit Profile” settings, and access the “SSH Key” settings. Then, add the public key in the given fields and specify its title. Next, hit the “Add key” button. Lastly, connect with the GitLab account by running the “ssh -T [email protected]” command. This blog elaborated on adding and configuring SSH keys on GitLab.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.