首页 > 解决方案 > 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。

标签: gitauthenticationnginxtortoisegitgogs

解决方案


Git 是一个“愚蠢的内容跟踪器”。它只跟踪内容,不提供或要求任何身份验证或授权。

如果您想要任何身份验证和/或授权,则需要以某种方式将其放在首位。

如果您使用 gogs,则需要在那里配置身份验证或从您的 nginx 代理传递用户名(参见https://github.com/gogits/gogs/issues/165https://github.com/gogits/gogs/问题/2170https://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 配置中提供静态凭据。


推荐阅读