0

On a Linux machine I want to clone GitHub repositories while being behind an NTLM proxy.

I know about the answers here on Stackoverflow (like A, B or C) about git and proxies, and I have in accordance with them done the following:

In my .gitconfig I have set the proxy information in the form of

[http]
    sslVerify = false
    proxy = http://<user>:<password>@<ip-adress>:<port-number>
[https]
    sslVerify = false
    proxy = http://<user>:<password>@<ip-adress>:<port-number>

(Note: I have tried it without disabling SSL as well.)

Furthermore I have set the environment variables

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

for the underlying curl calls.

Still I cannot connect. For example I issue

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

If beforehand I have switch on debug output via export GIT_CURL_VERBOSE=1 I get the following error message output:

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

Strange thing is, curl on its own works! So what is different between the fetching via git and curl? How can I make git clone <URL> work behind this type of proxy?

halloleo
  • 9,216
  • 13
  • 64
  • 122

1 Answers1

0

By digging deeper into StackOverflow I came to answers (like A and B) suggesting cntlm - and this finally works! So do the following:

Install cntlm on your machine, setup the config file with the proxy credentials, start cntlmd as a service and point from now on all other tools to the cntlm proxy (by default http://127.0.0.1:3128).

halloleo
  • 9,216
  • 13
  • 64
  • 122