Gitlab 简明教程

GitLab - SSH Key Setup

Description

SSH 代表安全外壳或安全套接字外壳,用于管理网络、操作系统和设定,还可以验证 GitLab 服务器,每次都无需使用使用者名称和密码。您可以设定 SSH 金钥,在计算机和 GitLab 之间提供稳固的连接。在产生 SSH 金钥之前,您需要在您的系统上安装 Git。

The SSH stands for Secure Shell or Secure Socket Shell used for managing the networks, operating systems and configurations and also authenticates to the GitLab server without using username and password each time. You can set the SSH keys to provide a reliable connection between the computer and GitLab. Before generating ssh keygen, you need to have Git installed in your system.

Creating SSH Key

Step 1 − 要产生 SSH 金钥,开启指令提示字元并输入如下所示的指令 −

Step 1 − To create SSH key, open the command prompt and enter the command as shown below −

C:\−ssh-keygen

将提示您键入「将金钥储存到的档案 (//.ssh/id_rsa):」,只要键入档案名称然后按 Enter 键即可。接着会出现提示您输入密码的提示字元,「输入密码短语 (空白代表不使用):」。输入一些密码然后按 Enter 键。您会看到产生出来的 SSH 金钥,如下图所示 −

It will prompt for 'Enter file in which to save the key (//.ssh/id_rsa):', just type file name and press enter. Next a prompt to enter password shows 'Enter passphrase (empty for no passphrase):'. Enter some password and press enter. You will see the generated SSH key as shown in the below image −

SSH Key 1

Step 2 − 现在登录到您的 GitLab 帐号,然后单击设定选项。

Step 2 − Now login to your GitLab account and click on the Settings option.

SSH Key 6

Step 3 − 要产生 SSH 金钥,请单击菜单左侧的 SSH 金钥选项标签。

Step 3 − To create SSH key, click on the SSH keys tab at left side of the menu.

SSH Key 5

Step 4 − 现在转到 C 驱动器,您将会看到第一个步骤中产生的带有 .pub 延伸模块的档案。

Step 4 − Now go to C drive, you will see the file with .pub extension which was generated in the first step.

SSH Key 4

Step 5 − 接下来的打开 key.pub 文件,复制 SSH 密钥并将其粘贴到突出显示的关键框中,如下图所示 −

Step 5 − Next open the key.pub file, copy the SSH key and paste it in the highlighted Key box as shown in the below image −

SSH Key 2

Step 6 − 在添加密钥按钮上单击,将 SSH 密钥添加到 GitLab。下图中所示,您会看到指纹(它是 SSH 密钥的短版本)、标题和创建日期 −

Step 6 − Click on the Add Key button, to add SSH key to your GitLab. You will see the fingerprint (it is a short version of SSH key), title and created date as shown in the image below −

SSH Key 3