GitLab:ssh添加公钥免密访问
通常,我们使用http方式访问gitlab并输入用户名称、密码鉴权然后clone仓库:
此外,也可以通过生成公私钥,并将公钥存储在gitlab中实现免密登陆。
1.公私钥生成
ssh-keygen -t rsa -b 2048
Microsoft Windows [版本 10.0.17763.107]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Users\EB>ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\EB/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\EB/.ssh/id_rsa.
Your public key has been saved in C:\Users\EB/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:i3DpYgszq+/6+R5JlugobTb+qymxLNHPrRdXTVqhJvk eb@DESKTOP-K45IA6V
The key's randomart image is:
+---[RSA 2048]----+
| .. |
| . .o |
| o o= |
| . . . +o . |
| .. = o S.E |
|o+.o =.... |
|++Xo=.oo. |
|== Xo+o |
|+BX=B+ |
+----[SHA256]-----+
生成的公私钥存储:C:\Users<user>.ssh(user是win用户名)
更多参考:
https://blog.csdn.net/test1280/article/details/118606652
2.设置gitlab
打开设置Edit profile:
打开设置SSH密钥:
复制拷贝id_rsa.pub公钥到gitlab的窗口:
点击添加密钥:
添加密钥完成:
3.测试免密
clone时,使用ssh协议进行clone:
ssh免密 clone 成功: