官术网_书友最值得收藏!

  • GitLab Cookbook
  • Jeroen van Baarsen
  • 346字
  • 2021-08-05 16:55:06

Adding your SSH key to GitLab

In order for GitLab to know who we are and check whether we are authorized to commit certain code, we use our SSH key. The combination of the public key and the private key can tell GitLab that we are authorized, and GitLab will allow the operation to be performed.

How to do it…

To set up your SSH key, perform the following steps:

  1. Open GitLab and go to your account settings.
  2. Click on SSH.
  3. Click on Add SSH Key.
  4. To get information about your SSH key, enter the following command in your terminal. If you're using Windows, go to step 7:
    $ cat ~/.ssh/id_rsa.pub
    
  5. You should copy the entire content of the output in step 4, as shown in the following screenshot:
  6. If you're not using Windows, you can move to step 11.
  7. Open the Windows explorer and move to C:\Users\your_username\.ssh.
  8. Right-click on id_rsa.pub and click on Open.
  9. When asked for the program you want to use, select Notepad.
  10. Select the entire content of the file that contains the SSH key.
  11. We now paste the content of the SSH key into the form in your GitLab instance. You can name the SSH key anything you want. It is recommended that you name it after the computer it came from. This way, it will be easier to know which key belongs to which machine. If you leave the name field empty, GitLab will generate a name for you.
  12. Now, click on Add Key.

How it works…

In order to make Git aware of your SSH key, you need to add the public portion of the key to GitLab. When you add the SSH key to GitLab, it will put the key for the Git user in the authorized_keys file on the GitLab server.

Whenever you will execute a Git command that will communicate with GitLab, it will check the permissions you have against your own user account.

One thing to remember is that you can only use one SSH key for one account, as it will be account-bound.

主站蜘蛛池模板: 巴南区| 纳雍县| 松江区| 布尔津县| 霍林郭勒市| 新田县| 巫溪县| 麻江县| 错那县| 叙永县| 沅江市| 开平市| 青岛市| 竹山县| 綦江县| 什邡市| 景德镇市| 禹州市| 东辽县| 和龙市| 禄劝| 紫金县| 宜昌市| 盐山县| 安化县| 邯郸市| 永福县| 郸城县| 廊坊市| 潜江市| 鲁甸县| 齐河县| 建水县| 邢台县| 淮北市| 邛崃市| 若羌县| 河间市| 泰和县| 惠东县| 云浮市|