git - http auth 不适用于 TortoiseGit
问题描述
每次我尝试从我们的远程 gogs 存储库中使用 TortoiseGit 克隆任何存储库时,我都会得到 401(未经授权)。
用作结帐http://user:pw@ex.ample.com/user/repo.git
网址也不起作用。
ssh 不是一个选项。一切都在禁用 http auth 的情况下工作。
简化的 nginx 配置:
server {
listen 80;
listen [::]:80;
server_name ex.ample.com;
location / {
auth_basic "Restricted Content";
auth_basic_user_file /var/www/gogs/.htpasswd;
proxy_pass http://localhost:3000/;
}
}
所以我的问题是:如何配置 TortoiseGit 以发送有效的 http auth?
编辑:似乎只影响私人回购,公共回购是可访问的。
Edit2:在 http auth 之后也无法推送到公共仓库。
解决方案:https
反向代理的行为很奇怪,所以 repo url 和 push url 必须与普通 http 一起使用。可能这里需要一些 nginx tweeking。
解决方案
Git 是一个“愚蠢的内容跟踪器”。它只跟踪内容,不提供或要求任何身份验证或授权。
如果您想要任何身份验证和/或授权,则需要以某种方式将其放在首位。
如果您使用 gogs,则需要在那里配置身份验证或从您的 nginx 代理传递用户名(参见https://github.com/gogits/gogs/issues/165,https://github.com/gogits/gogs/问题/2170,https://github.com/gogits/gogs/pull/3785,...)。
有关使用 http 服务 Git 的其他方法,请参阅如何使用用户/密码通过 NGINX 通过 HTTP 服务 GIT?或http://gitolite.com/gitolite/http/。
老答案:
使用基本身份验证只能有一个身份验证,而不是两个甚至更多。
唯一的例外是代理身份验证(http 状态代码 407,它使用不同的标头完成)。
您可以尝试通过代理凭据https://serverfault.com/q/511206/237109将您的基本身份验证凭据转发到您的其他服务器,或者尝试在您的 nginx 配置中提供静态凭据。
推荐阅读
- jvm - 为什么 CONSTANT_Long_info 和 CONSTANT_Double_info 仍然是 2 个整数?
- angular - Angular 6:如何注册 canDeactivate 防范所有路由
- sql - 将两个日期和时间之间的日期转换为一个月的第一天
- memory-management - 内存映射的 I/O 地址和 RAM 地址是否相关?
- jquery - 运行 jquery 每个循环,每个循环之间有延迟
- react-native - React Native 应用无法正确安装
- node.js - 使用 NodeJS+express 在 Cloud Foundry 应用程序中进行相互身份验证
- php - 如何使用 PHP 变量设置进度条的宽度
- tortoisegit - 如何在 TortoiseGit 日志中查看 Git 提交 ID
- pdf - 如何使用 ghostscript 模拟 pdf 设备的叠印