GitLab:免密认证鉴权
GitLab支持多种协议,常用的有http以及ssh。
GitLab如何设置免密认证鉴权呢?
1.http免密
通过设置netrc实现http免密。
1.1.windows配置
新建windows环境变量:HOME(%USERPROFILE%)
注:%USERPROFILE%通常为C:\Users<user>(user是win用户名)
在%HOME%目录中,新建_netrc文件:(无任何后缀)
编辑输入:
machine gitlab.xxx.com
login <username>
password <password>
其中username、password即为你在gitlab的用户名称、密码。
测试验证:
EB@DESKTOP-K45IA6V MINGW64 ~/Desktop/tmp
$ git clone https://gitlab.xxx.com/yyy/test1280.git
Cloning into 'test1280'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
1.2.linux配置
在$HOME中新增.netrc文件:
machine gitlab.xxx.com login <username> password <password>
测试验证:
[root@localhost ~]# git clone https://gitlab.xxx.com/yyy/test1280.git
Cloning into 'test1280'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
2.ssh免密
2.1.windows
参考:
https://blog.csdn.net/test1280/article/details/118608774
2.2.linux
类比 2.1.windows 方式,在linux中生成公私钥,然后在gitlab设置公钥即可。