How to access google/github respository behind VPN?

5,464

I manage to access any external repo behind firewall without any issue, provided I have my proxy settings in place:

HTTPS_PROXY=http://username:[email protected]:port
HTTP_PROXY=http://username:[email protected]:port 

Note that both addresses the same proxy address (in my case, an http, not https one), with the username and password for that proxy (not for GitHub)

~/.netrc (or %HOME%/_netrc on Windows, if you defined explicitly an %HOME% environment variable) is only used for the external repo authentication:

machine github.com
login user
password passwd

See "Git - How to use .netrc file on windows to save user and password" for more.

Share:
5,464

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I cannot check out both code.google.com and github projects via git, but I can normally access them from IE/Firefox browser. There were a lot of discussions about git proxy configuration behind firewall but unfortunately none of these discussions is suitable for my problem.

    Here are the messages while I am trying to access code.google.com

    Cloning into 'smart-adaptive-makefile'...
    * Couldn't find host code.google.com in the .netrc file; using defaults
    * About to connect() to proxy proxyconf port 1080 (#0)
    *   Trying 147.243.224.17...
    * 0x80077208 is at send pipe head!
    * STATE: CONNECT => WAITCONNECT handle 0x8007fba0; (connection #0)
    * Connection timed out after 300015 milliseconds
    * STATE: WAITCONNECT => COMPLETED handle 0x8007fba0; (connection #-5000)
    * STATE: COMPLETED => MSGSENT handle 0x8007fba0; (connection #-5000)
    * Closing connection #0
    * Couldn't find host code.google.com in the .netrc file; using defaults
    * About to connect() to proxy proxyconf port 1080 (#0)
    *   Trying 147.243.224.17...
    * 0x80077208 is at send pipe head!
    * STATE: CONNECT => WAITCONNECT handle 0x8007fad8; (connection #0)
    * Connection timed out after 300032 milliseconds
    * STATE: WAITCONNECT => COMPLETED handle 0x8007fad8; (connection #-5000)
    * STATE: COMPLETED => MSGSENT handle 0x8007fad8; (connection #-5000)
    * Closing connection #0
    error: Connection timed out after 300032 milliseconds while accessing https://[email protected]/p/smart-adaptive-makefile/info/refs
    fatal: HTTP request failed
    

    BTW, my IE/Firefox uses an automatic configuration script instead of manually configuration proxy server. In this case, how should I configure git?

    BR,ruochen

    • Admin
      Admin over 11 years
      are you accessing git repository using https or git protocol?
    • Admin
      Admin over 11 years
      I access git repository via https
  • Admin
    Admin over 11 years
    Basically your solution works. Simply setting http.proxy in git is okay. It is not necessary to setting HTTP_PROXY/HTTPS_PROXY environment variables. I got the problem because I used to set http.proxy directly to the automatic configuration script which was copied from the browser setting. Now I open that script and manually pick up the proxy server address and set it to git and solve the problem.
  • VonC
    VonC over 11 years
    @PRC true, but I need those for other programs to work, and I prefer don't leave my username / password in git config files. I define those variable in a DOS session each time I need them.