DEV Community

Khairun Nahar Nowrin
Khairun Nahar Nowrin

Posted on

Generate SSH key

To add an SSH key to your GitLab account, you will need to follow these steps:

  1. Generate an SSH key on your computer. This can be done by running the following command in a terminal window:
ssh-keygen -t rsa -b 4096 -C "<your email address>"
Enter fullscreen mode Exit fullscreen mode

Replace with the email address associated with your GitLab account. This will generate a public and private SSH key on your computer.

  1. Copy the contents of the public SSH key. This can be done by running the following command in a terminal window:
cat ~/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode

This will display the contents of the public SSH key on your screen. Copy the entire key, including the ssh-rsa prefix and the suffix.

  1. Go to your GitLab profile settings and click on the "SSH Keys" tab.

  2. Click on the "Add SSH Key" button.

  3. Paste the contents of the public SSH key into the "Key" field.

  4. Give the SSH key a title in the "Title" field. This can be anything that helps you identify the key, such as the name of the computer it was generated on.

  5. Click on the "Add Key" button.

  6. After adding the SSH key to your GitLab account, you can use it to authenticate yourself when pushing and pulling changes from GitLab repositories. This will allow you to use the ssh protocol instead of the https protocol, which can be faster and more secure.

To add an SSH key to your GitHub account, you will need to follow these steps:

  1. Generate an SSH key on your computer. This can be done by running the following command in a terminal window:
ssh-keygen -t rsa -b 4096 -C "<your email address>"
Enter fullscreen mode Exit fullscreen mode

Replace with the email address associated with your GitHub account. This will generate a public and private SSH key on your computer.

  1. Copy the contents of the public SSH key. This can be done by running the following command in a terminal window:
cat ~/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode

This will display the contents of the public SSH key on your screen. Copy the entire key, including the ssh-rsa prefix and the suffix.

  1. Go to your GitHub profile settings and click on the "SSH and GPG keys" tab.

  2. Click on the "New SSH Key" button.

  3. Paste the contents of the public SSH key into the "Key" field.

  4. Give the SSH key a title in the "Title" field. This can be anything that helps you identify the key, such as the name of the computer it was generated on.

  5. Click on the "Add SSH Key" button.

After adding the SSH key to

Top comments (0)