DEV Community

Cover image for Add SSH key in GitLab account
Nitin Kumar
Nitin Kumar

Posted on

Add SSH key in GitLab account

Today, we'll see how we can add SSH key to our GitLab account so that we can push, pull & perform tasks from our GitLab in local machine.

First, we need to have a GitLab account without any SSH key (preferred).

No SSL certificate

Now, we need to create SSL certificate. Remember, Gitlab only allows some hashing methods for this. Following is the list:

List of hashing methods

Now, we need to open Command Prompt in our local machine & enter following command:-

ssh-keygen -t ed25519 -C "YOUR_MAIL_ID"
Enter fullscreen mode Exit fullscreen mode

; since I want to use ed25519 hashing algo, I've used that. For others, use those names.

Then, just press enter for the prompts, for simplicity, it'll ask for the filename & any passphrase we wanna use.
Keys will be generated after you press enter. It'll look like this :-

Generated keys

Now, files will be generated like below :-

Files generated

You open the file with extension .pub just generated & copy whole file content.

Go to the SSL page in Gitlab & click on Add new Key button

In the SSL content, paste the key copied from file.
Put other details as needed & click on Add Key button.

Your key will be added successfully with other SSH key & fingerprint details.

Now, just to check your gitlab is connected to your local machine, put below command & press Enter :-

 ssh -vT git@gitlab.com
Enter fullscreen mode Exit fullscreen mode

You must see a message 'Welcome to Gitlab, [YOUR_USERNAME]!' in the screen along with some other details.

Validating github connection


Feel free to reach out to me via LinkedIn, Instagram or checkout my Portfolio.

HAPPY HACKING !!!

Top comments (0)