GitLab:免密认证鉴权

本文介绍了如何在GitLab中设置http和ssh免密认证。对于http免密,无论是Windows还是Linux,都需要创建_netrc文件并填入用户名和密码。对于ssh免密,Windows用户可参考相关教程,Linux用户则需要生成公私钥对并将公钥添加到GitLab。通过这些步骤,可以实现与GitLab交互时的免密克隆和推送。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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设置公钥即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值