tags:

views:

702

answers:

3

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.

I dig through google search and i can't find any helpful results.

Thxs.

+1  A: 

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.

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.

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. Squid supports this mode of operation, though the configuration can be a little complex; I found an example configuration that purports to demonstrate this setup, though I haven't verified that it works myself.

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:

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.

Brian Campbell
So you're telling me to install squid as local proxy ??? Thxs by the help.
erick2red
Yes, I'm recommending that you set up Squid as a local proxy server (on the same machine that Git is running on), with no authentication, and have Squid connect to your proxy server that has authentication. Then just configure Git to use your local Squid as its proxy server.
Brian Campbell
Thxs you, very much (trying to reach 15 chars).
erick2red
Sorry, I realized that Squid doesn't support that usage; it only supports basic auth for upstream proxies, not digest. Added some more recommendations.
Brian Campbell
Already patched git, thxs for the help.
erick2red
Have you sent the patch upstream? I'd recommend that, if you can.
Brian Campbell
A: 

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.

Greg Bacon
+2  A: 

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

Then a plain ole git clone worked.

(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.)

Bennett McElwee