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

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.

主站蜘蛛池模板: 永州市| 崇礼县| 东城区| 安塞县| 博野县| 多伦县| 庄浪县| 南岸区| 荥阳市| 泰宁县| 游戏| 普安县| 柘荣县| 化隆| 双峰县| 房产| 乃东县| 南召县| 密山市| 伽师县| 惠州市| 承德县| 嘉定区| 防城港市| 兰考县| 忻城县| 射洪县| 中卫市| 铁力市| 金山区| 四川省| 南溪县| 新津县| 高青县| 崇义县| 龙江县| 南澳县| 嵊泗县| 佳木斯市| 遂平县| 泗水县|