Reputation: 1310
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.
Upvotes: 20
Views: 42488
Reputation: 151
Using
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
hope this will help as I usually get mad about this...
Upvotes: 3
Reputation: 1324417
Note that Git does support http proxies since Git 1.7.10, Apr. 2012, commit dd61399.
But, that supposes you have curl 7.10.7+ installed, which is something Git wasn't checking before Git 2.3.2+ (Q1 2015)
This is fixed with commit 1c2dbf2 by Tom G. Christensen (tgc
)
http: support curl < 7.10.7
Commit dd61399 introduced 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.
Upvotes: 3
Reputation: 2192
Just to save a few moments of googling on Bennet's Answer:
>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
NOTE: When you verify, you should see the same values that you put in.
Upvotes: 35
Reputation: 25760
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.)
Upvotes: 17
Reputation: 332846
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.
Upvotes: 1
Reputation: 139471
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.
Upvotes: 0