Git 通过摘要代理认证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2088156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git through digest proxy authentication
提问by erick2red
I want to do "git clone" through a proxy server. The issue is my proxy server uses digest authentication. So i can't find neither in git documentation, nor help that someone that already made.
我想通过代理服务器执行“git clone”。问题是我的代理服务器使用摘要式身份验证。所以我既无法在 git 文档中找到,也无法帮助已经做过的人。
I dig through google search and i can't find any helpful results.
我通过谷歌搜索挖掘,我找不到任何有用的结果。
Thxs.
谢谢。
回答by Delicia Brummitt
Just to save a few moments of googling on Bennet's Answer:
只是为了节省谷歌搜索 Bennet 的答案的片刻时间:
- Clear old settings:
>git config --global --unset https.proxy
>git config --global --unset http.proxy
Set new settings:
>git config --global https.proxy https://USER:[email protected]:80
>git config --global http.proxy http://USER:[email protected]:80
Verify new settings:
>git config --get https.proxy
>git config --get http.proxy
- 清除旧设置:
>git config --global --unset https.proxy
>git config --global --unset http.proxy
设置新设置:
>git config --global https.proxy https://USER:[email protected]:80
>git config --global http.proxy http://USER:[email protected]:80
验证新设置:
>git config --get https.proxy
>git config --get http.proxy
NOTE: When you verify, you should see the same values that you put in.
注意:当您验证时,您应该看到与您输入的值相同的值。
回答by Bennett McElwee
I was able to do a git clone through an authenticated proxy by setting the environment variable http_proxy
to http://username:password@proxyhost:80
我能够通过身份验证的代理做一个git克隆环境变量设置http_proxy
到http://username:password@proxyhost:80
Then a plain ole git clone
worked.
然后一个普通的olegit clone
工作了。
(The proxy is some corporate Windows thing, so my username actually looked like domain\username. Took a while to realise that I needed the domain.)
(代理是一些 Windows 公司的东西,所以我的用户名实际上看起来像域\用户名。花了一段时间才意识到我需要域。)
回答by VonC
Note that Git does support http proxies since Git 1.7.10, Apr. 2012, commit dd61399.
请注意,自2012 年 4 月 Git 1.7.10 提交 dd61399以来,Git 确实支持 http 代理。
But, that supposes you have curl 7.10.7+ installed, which is something Git wasn't checking before Git 2.3.2+ (Q1 2015)
但是,假设您安装了 curl 7.10.7+,这是 Git 在 Git 2.3.2+(2015 年第一季度)之前没有检查过的
This is fixed with commit 1c2dbf2by Tom G. Christensen (tgc
)
这已通过Tom G. Christensen ( ) 的commit 1c2dbf2修复tgc
http: support curl < 7.10.7
http: 支持 curl < 7.10.7
Commit dd61399introduced support for http proxies that require authentication but it relies on the
CURL_PROXYAUTH
option which was added in curl 7.10.7.
This makes sure proxy authentication is only enabled if libcurl can support it.
Commit dd61399引入了对需要身份验证的 http 代理的支持,但它依赖
CURL_PROXYAUTH
于 curl 7.10.7 中添加的选项。
这确保仅在 libcurl 支持时才启用代理身份验证。
回答by Badjem79
Using
使用
git config --global http.proxy
git config --global http.proxy
or more in general, if the user or password has any special char like "$\" etc you gotta url encode it making then something like: %24%5C
或者更一般地说,如果用户或密码有任何特殊字符,如“$\”等,您必须对其进行 url 编码,然后类似于:%24%5C
hope this will help as I usually get mad about this...
希望这会有所帮助,因为我通常对此很生气......
回答by Brian Campbell
Git does not appear to support authenticated proxy servers. You can check http.c
from the git.git repository; in order to support authenticated proxy servers at all, it would have to set CURL_PROXYUSERPWD
to set the username and password, but that string does not appear in that file.
Git 似乎不支持经过身份验证的代理服务器。您可以http.c
从 git.git 存储库中查看;为了完全支持经过身份验证的代理服务器,它必须CURL_PROXYUSERPWD
设置用户名和密码,但该字符串不会出现在该文件中。
One possible solution would be to fix Git; add a few more configuration parameters to http.c
, such as http.proxyuser
, http.proxypass
, to set the username and password for the proxy, and http.proxyauth
to set the authentication method, and then pass those in as the appropriate cURL configuration options.
一种可能的解决方案是修复 Git;向 中添加更多配置参数http.c
,例如http.proxyuser
,http.proxypass
设置代理的用户名和密码,以及http.proxyauth
设置身份验证方法,然后将它们作为适当的cURL 配置选项传入。
If you don't feel like hacking on the Git source code, you could set up your own, local proxy server, that needs no authentication, and then forward from that to the proxy server that requires authentication. Squidsupports this mode of operation, though the configuration can be a little complex; I found an example configurationthat purports to demonstrate this setup, though I haven't verified that it works myself.
如果您不想修改 Git 源代码,您可以设置自己的本地代理服务器,不需要身份验证,然后从该服务器转发到需要身份验证的代理服务器。Squid支持这种操作模式,虽然配置可能有点复杂;我发现了一个旨在演示此设置的示例配置,但我还没有验证它是否可以自己工作。
edit: Never mind, after checking the Squid source code, it appears to only support Basic authentication, not Digest authentication, when forwarding requests to a peer:
编辑:没关系,在检查Squid 源代码后,在将请求转发给对等方时,它似乎只支持基本身份验证,而不支持摘要身份验证:
httpHeaderPutStrf(hdr_out, header, "Basic %s", base64_encode(orig_request->peer_login));
I haven't found any proxy servers that can pass a request along to another proxy with digest authentication enabled; if you can find one that supports digest auth for an upstream proxy, I'd recommend using that.
我还没有找到任何代理服务器可以将请求传递给另一个启用了摘要身份验证的代理;如果你能找到一个支持上游代理的摘要认证,我建议你使用它。
Otherwise, I'd recommend using a different protocol than HTTP; use ssh:
if you need authentication, or the raw git:
protocol if you're just pulling changes down from a public server.
否则,我建议使用与 HTTP 不同的协议;使用ssh:
,如果你需要验证,或原始git:
协议,如果你只是拉变化从公共服务器停机。
回答by Greg Bacon
If you're cloning over SSH, the answer to the closely related question How do I use GitHub through harsh proxies?looks adaptable to your situation, but instead of Corkscrew, which doesn't yet support digest authentication, use tunnel-auth.pl
from CPAN.
如果您通过 SSH 进行克隆,那么密切相关问题的答案如何通过苛刻的代理使用 GitHub?看起来适合您的情况,但不是Corkscrew,它不支持摘要身份验证,而是tunnel-auth.pl
从 CPAN使用。