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

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.

主站蜘蛛池模板: 菏泽市| 灌阳县| 孟连| 眉山市| 成都市| 将乐县| 邮箱| 蓬安县| 杭锦后旗| 寿光市| 襄垣县| 怀化市| 大埔区| 宣恩县| 东光县| 昭平县| 安泽县| 北流市| 鄂温| 东台市| 博兴县| 呈贡县| 汾西县| 长宁区| 本溪| 喀什市| 凉城县| 南昌县| 栖霞市| 中方县| 雷州市| 麻江县| 南投县| 新乡市| 讷河市| 海林市| 普兰店市| 新乐市| 浪卡子县| 乌拉特中旗| 高密市|