29

I want to connect to GitHub at work and need to get through the http proxy. I am able to get out for FTP using cURL using the command

curl -v -g --ftp-pasv --upload-file MYFILE --proxy PROXYADDRESS:PROXYPORT --proxy-ntlm --proxy-user WINDOWSDOMAIN\WINDOWSUSER:WINDOWSPASSWORD ftp://FTPUSER:FTPPASS@FTPURL/

I've so far not been able to provide equivalent settings for Git.

I tried following instructions on Using Github Through Draconian Proxies under cygwin.

I've got corkscrew installed and tried to SSH to GitHub

ssh github.com

or

ssh ssh.github.com

I get back

ssh: Could not resolve hostname ssh.github.com: hostname nor servname provided, or not known.

I've tried setting the http and https proxy.

Here is the output from git --config -l

core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=C:/Program Files/Git/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
user.name=Peter Wilkinson
user.email=someemail@gmail.com
github.user=ProggerPete
github.token=shouldprobablykeepthissecret
http.proxy=http://somedomain\someuser:somepass@10.167.116.142:80
https.proxy=http://somedomain\someuser:somepass@10.167.116.142:80

I've also run

export https_proxy=http://somedomain\someuser:somepass@10.167.116.142:80
export http_proxy=http://somedomain\someuser:somepass@10.167.116.142:80
set https_proxy=http://somedomain\someuser:somepass@10.167.116.142:80
set http_proxy=http://somedomain\someuser:somepass@10.167.116.142:80

I then try and clone and get.

$ git clone https://ProggerPete@github.com/project/JavaScript-Maven-Plugin.git
Cloning into JavaScript-Maven-Plugin...
Password:
error: The requested URL returned error: 407 while accessing https://ProggerPet
@github.com/project/JavaScript-Maven-Plugin.git/info/refs

fatal: HTTP request failed

This looks to me like I'm failing authentication with the proxy. However I'm using the same login and pass that works for FTP via cURL.

How can I get connected?

random
  • 9,774
  • 10
  • 66
  • 83
Programming Guy
  • 7,259
  • 11
  • 50
  • 59
  • possible duplicate of [How do I pull from a Git repository through an HTTP proxy?](http://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy) – KindDragon Dec 10 '13 at 12:54
  • could you please help me with - http://stackoverflow.com/questions/21600830/ssh-ing-to-remote-server-from-behind-a-proxy – whatf Feb 06 '14 at 10:56

4 Answers4

29

After much head bashing I finally stumbled across http://cntlm.sourceforge.net/. It's a proxy proxy that understands ntlm authentication.

I installed it and told it about the http proxy. Then pointed git at CNTLM and it all started working.

I found getting this going very frustrating so hopefully this will help someone else in the same situation.

Programming Guy
  • 7,259
  • 11
  • 50
  • 59
  • That is good to know about. Proxies that only do NTLM authentication are known to be a problem and this looks like a useful work-around. The version of curl provided with msysGit can do NTLM but I seem to remember that git doesn't pass authentication parameters to it. – patthoyts Oct 19 '11 at 09:09
  • Yeah, I could get the curl in msysgit to talk to the proxy from command line, but there seemed no way to pass the the --proxy-ntlm flag when git was using it. – Programming Guy Oct 20 '11 at 00:07
  • I am having a similar issue, I cannot use git or ssh into my boxes at work. Does this solution work on ubuntu too? And could you please elaborate on `pointed git at CNTLM`. I am still in the head bashing phase. – awm Nov 29 '12 at 05:08
  • @ali Do you have NTLM to deal with? I don't seem to need it, though I am running Ubuntu server on an AD/Windows network. I don't know what kind of proxy server is in my way, though. – Phil Hord Feb 15 '13 at 16:03
  • 1
    The newest 1.8 msysGit can now speak NTLM, including GSSPI for smartcards (Thanks CURL!) – Adam Baxter Jun 28 '13 at 04:46
  • ntlmaps if very good also, and it doesn't require admin rights – Juancentro Aug 30 '13 at 18:56
  • @PeterWilkinson Whould you like to introduce step by step to How to pass git through proxy? :/ – Dr.jacky Jun 19 '14 at 06:03
12

I usually only need to set:

set http_proxy=http://<login_internet>:<password_internet>@aproxy:aport
set https_proxy=http://<login_internet>:<password_internet>@aproxy:aport

(note the https_proxy refers to the same http, not https, proxy address)

See also "Cannot get Http on git to work".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
6

You can put proxy information in your ~/.curlrc:

/home/usr/.curlrc

proxy = proxy.proxyhost.com:8443
proxy-user = user:pass
proxy-ntlm = true
noproxy = localhost,127.0.0.1,intraweb.company.com

jeckhart
  • 571
  • 3
  • 10
2

You are unlikely to be able to get ssh to github tunnelled through your proxy. However as github provides https urls for all their repositories and you can push to that you don't need ssh. If you already have a repository checked out, you can change the url used with

git remote set-url origin https://github.com/project/repo.git
git remote set-url --push origin https://YOURNAME@github.com/project/repo.git

(skip the second line if you do not need push access). This, along with setting the environment variables (https_proxy) as mentioned by VonC will enable access via your proxy.

patthoyts
  • 32,320
  • 3
  • 62
  • 93
  • I don't have a repo checked out. I'm trying to check one out using git clone https://ProggerPete@github.com/project/JavaScript-Maven-Plugin.git – Programming Guy Oct 19 '11 at 00:19