在终端输入命令:$ cd ~/.ssh
查看是否存在ssh文件
- 存在
打开终端输入 open ~/.ssh
cat id_rsa.pub //打开id_rsa.pub文件,复制密钥
- 不存在
$ ssh-keygen -t rsa -C "邮箱地址" #邮箱地址为公司的gitlab邮箱,生成KEY
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/用户/.ssh/id_rsa): //密钥的目录
Created directory '/c/Users/用户/.ssh'.
Enter passphrase (empty for no passphrase): //密码设置为空
Enter same passphrase again:
Your identification has been saved in /c/Users/用户/.ssh/id_rsa.
Your public key has been saved in /c/Users/用户/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:******* **** //公钥
The key's randomart image is:
+---[RSA 3072]----+
| o.*+ . .o.. |
| + *o*. .. . |
| *.B o |
| +. . . .|
| . S E . . |
| . . + = .o |
| . . + +.*. . |
| . o.+o@. |
| o*B.o |
+----[SHA256]-----+