Five Easy Steps To Setup An SSH Key On GitLab

When you are attempting to clone a remote repository onto your local computer, one of the most important steps that you need to take is to set up an SSH key with the appropriate credentials. You will not be able to clone the file and will see error messages if you do not properly configure the SSH key. Sometimes it is challenging for beginners to comprehend and adhere to the instructions provided in the GitLab documentation for setting up an SSH key.

In this tutorial, I will simplify the steps for setting up the SSH key on GitLab.

Step 1: Login to your GitLab Account

First things first, you will need to sign in to your GitLab account.

Step 2: Navigate to Gitlab Preferences

Next, click on the user avatar icon in the menu at the top. From the dropdown, click on the link that says “Preferences/Edit Profile.”

Navigate to Gitlab Preferences

Step 3: Navigate to the SSH Keys

Now, click on the SSH Keys link in the window on the left. That page will now have our SSH public key on it. To do that, we need the public key for our local computer. In the next step, we will learn how to get the public key.

Navigate to the SSH Keys

Step 4: Copy SSH Public Key

After that, we need to open the terminal app on our computer and type the following instructions to get to the “.ssh” folder. Here is an example of the command and what it does.

cd ~/.ssh
Go to the ssh folder

Next, write the following command to print/display the ssh public key.

cat id_rsa.pub
bash print command to display the ssh public key

Select all and copy it. For this example, start copying from the “ssh-rsa” text and end at the “local” text.

Now, go to the GitLab SSH Keys page and paste the public key there. Finally, click the Add key button.

Five Easy Steps to setup a GitLab SSH Key

You will find your newly added key information on the SSH keys page.

Step 5: Try to clone any GitLab repository

Now, we are ready to clone any public GitLab repository. Go to any repository and click on the code button. Copy the Clone with SSH link from there.

clone git repository

Write the following git clone command and append the link to it. Example-

git clone <CLONE_WITH_SSH_URL>

As you clone the repository for the first time, your computer will ask you to store the fingerprint in it’s known hosts file. Write yes, and it will start cloning the repository.

Clone a git repository with ssh key

You will be able to retrieve all of the files from the remote repository onto your computer if everything is carried out in the appropriate manner. You are now able to make modifications to the files, create new branches, and push them to the remote source using the remote source.

Thank you for reading the post, and I really hope that this guide is helpful. If you have any questions, please leave them in the comments section, and I will get back to you.

, ,

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*

Back To Top