Random Tech Thoughts

The title above is not random

Git Http/ssh/git Protocol Through HTTP Proxy

My university network only gives us access to CERNET. This causes trouble when I need to access resources outside CERNET. Luckily, many applications support HTTP proxy, and git works with proxy very well.

Using http protocol to access a git repository is the most simple way. Set an environment variable is enough. “export http_proxy=proxyhost:proxyport”. If your proxy requires authentication, “export http_proxy=http://username:passwd@proxyhost:proxyport” should work. (I didn’t tested the later one. man libcurl-tutorial if you want to see the magic behind this syntax.)

For ssh/git protocol, we need to create an http tunnel using either corkscrew/socat/connect-proxy (I used corkscrew). Note that the proxy server needs to allow connect to the destination port. (If your proxy server only allows connect to 80/443 port, this will not work.)

To use git protocol, you can find instructions here.

To use ssh protocol, ssh magic is needed. Take a look here.