要生成新的密匙,请在命令终端中执行以下操作。如果不需要更改默认的密匙存放地址,根据提示按回车键:
ssh-keygen -t rsa -C “your_email@example.com”
Generating public/private rsa key pair.(生成公私钥)
Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter] (默认位置就行)
接下来,你会被要求键入密码:
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
密码可以为空。当输完密码后,你会看到如下提示:
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
在 C:\用户\你的用户目录.ssh 目录下新建 config 文件, 文件里录写入下述内容
Host git.cairenhui.com
HostName git.cairenhui.com
Port 8244
User git
IdentityFile C:\用户\你的用户目录.ssh\id_rsa
在命令终端中输入:
ssh -T git@git.cairenhui.com
不出意外的话,你会看见以下提示:
The authenticity of host ‘git.cairenhui.com (172.16.1.50)’ can’t be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
别担心,第一次都会有此提示,应该是类似指纹识别之类的东东,输入 yes 继续。
当看到终端提示:
Welcome to GitLab, yourname!
恭喜你,大功告成!