git中代理问题(在Linux上是一个NTLM代理)

时间:2018-04-17 08:41:28

标签: git http github proxy ntlm-authentication

在Linux机器上,我想在NTLM代理后面克隆GitHub存储库。

我知道Stackoverflow上的答案(如ABC)关于git和代理人的答案,我按照他们的说法完成了以下操作:

在我的.gitconfig我已经以

的形式设置了代理信息
[http]
    sslVerify = false
    proxy = http://<user>:<password>@<ip-adress>:<port-number>
[https]
    sslVerify = false
    proxy = http://<user>:<password>@<ip-adress>:<port-number>

(注意:我已尝试过,但也没有禁用SSL。)

此外,我设置了环境变量

HTTP_PROXY=http://<user>:<password>@<ip-adress>:<port-number>
HTTPS_PROXY=http://<user>:<password>@<ip-adress>:<port-number>

用于基础curl来电。

我仍然无法连接。例如,我发出

git clone http://github.com/doorOfChoice/json-view

如果我事先通过export GIT_CURL_VERBOSE=1打开调试输出,我会收到以下错误信息输出:

Cloning into 'json-view'...
* Couldn't find host github.com in the .netrc file; using defaults
* About to connect() to proxy <ip-address> port <port-number> (#0)
*   Trying <ip-address>... * Connected to <ip-address> (<ip-address>) port <port-number> (#0)
> GET http://github.com/doorOfChoice/json-view/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/2.6.0
Host: github.com
Accept: */*
Accept-Encoding: gzip
Proxy-Connection: Keep-Alive
Accept-Language: en-US, *;q=0.9
Pragma: no-cache

< HTTP/1.1 407 Proxy Access Denied
< Expires: 0
< Server: WebMarshal Proxy
< Cache-Control: no-cache
< Connection: keep-alive
< Proxy-Connection: keep-alive
< Via: 1.1 WEBMARSHAL
< Content-Length: 2339
< Content-Type: text/html; charset=utf-8
< Proxy-Authenticate: Negotiate
< Proxy-Authenticate: NTLM
< Proxy-Authenticate: Basic realm="WebMarshal Proxy Server"
< X-WebMarshal-RequestID: <request-id>
< 
* Ignoring the response-body
* Expire cleared
* Connection #0 to host <ip-address> left intact
* Issue another request to this URL: 'http://github.com/doorOfChoice/json-view/info/refs?service=git-upload-pack'
* Couldn't find host github.com in the .netrc file; using defaults
* Re-using existing connection! (#0) with host <ip-address>
* Connected to <ip-address> (<ip-address>) port <port-number> (#0)
> GET http://github.com/doorOfChoice/json-view/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: git/2.6.0
Host: github.com
Accept: */*
Accept-Encoding: gzip
Proxy-Connection: Keep-Alive
Accept-Language: en-US, *;q=0.9
Pragma: no-cache

< HTTP/1.1 407 Proxy Access Denied
< Expires: 0
< Server: WebMarshal Proxy
< Cache-Control: no-cache
< Connection: keep-alive
< Proxy-Connection: keep-alive
< Via: 1.1 WEBMARSHAL
< Content-Length: 2339
< Content-Type: text/html; charset=utf-8
* gss_init_sec_context() failed: : Credentials cache file '<tmp-file>' not found< Proxy-Authenticate: Negotiate
< Proxy-Authenticate: NTLM
< Proxy-Authenticate: Basic realm="WebMarshal Proxy Server"
< X-WebMarshal-RequestID: <request-i>dstack
< 
* Connection #0 to host <ip-address> left intact
fatal: unable to access 'http://github.com/doorOfChoice/json-view/': The requested URL returned error: 407

奇怪的是, curl对它自己有效!那么通过git和curl获取之间有什么不同?如何让git clone <URL>在这种代理背后工作?

1 个答案:

答案 0 :(得分:0)

通过深入挖掘StackOverflow,我得到了答案(如AB)建议cntlm - 这终于有效了!请执行以下操作:

在您的计算机上安装cntlm,使用代理凭据设置配置文件,启动cntlmd作为服务,并从现在开始将所有其他工具指向cntlm代理(默认情况下{{3} })。