1、安装git(如果电脑上已经安装,请忽略)
2、单击鼠标右键,选择Git Bush here,打开git bush。
3、检查SSH keys是否存在,输入命令 : ls ~/.ssh
如果控制台没有输出任何内容,则表示git尚未生成过公私钥,可以继续下面操作
4、创建密钥,键入命令:如下命令,引号中是你在github上的注册邮箱:
Git bash执行:
ssh-keygen -m PEM -t rsa -b 4096 -C "XXXX@163.com"
只需要回车继续执行,使用默认设置即可
Administrator@SC-202008131201 MINGW64 ~/Desktop
$ ssh-keygen -m PEM -t rsa -b 4096 -C "xxxx@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): d:/ssh/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in d:/ssh/id_rsa.
Your public key has been saved in d:/ssh/id_rsa.pub.
The key fingerprint is:
SHA256:R4/ioIFlgC9JrJlLEw6E5rTmyp+Ln05pFSe1xDwpsrc xxx@qq.com
The key's randomart image is:
+---[RSA 4096]----+
|+o. oo. |
|+* o .o=. |
|O=o =o.o. . |
|*B.= .+ . o |
|+oo o.o S o . |
|.. oE o o |
|o +. . |
|..+ o |
| .+B. |
+----[SHA256]-----+
其中 d:/ssh/id_rsa 为公私钥的存储位置
5、打开文件: d:/ssh/id_rsa/id_rsa.pub ,复制文件全部内容
6、登录gitlab系统(登录的用户必须是管理员),头像右侧更多菜单->setting–>ssh![请添加图片描述](https://img-blog.csdnimg.cn/4e3a2cd341e04b99a0ad17878c3c5537.png
进入设置管理页面,点击菜单SSH keys(下图1),在位置2输入复制的公钥内容,点击按钮ADD KEY(位置3)即可