how to jail break with git

Certainly quite a few people suffer from too restrictive networks where you need to use proxy servers to reach outside world. Often applications support using HTTP or FTP proxies. But only few applications do also support SOCKS proxy for arbitrary protocols.

Guess what.. there are tricks to circumvent that 😉

 

Ingredients

  • existing SOCKS proxy reachable on the network
  • netcat

As an example I’ll describe how to connect with git to a remote repository via netcat through a SOCKS proxy. Git command line client itself doesn’t support SOCKS proxies directly. But it does support a proxy command. So we abuse netcat to do the conversion for git.

1.) Step – create a shell script

As git can only handle a proxy command without any parameter we create a small shell script to act as that command:

#!/bin/bash
nc -xproxy.mydomain.com:1080 -X5 $*

Save this as proxy_command.sh and give it execution rights.

Now export an environment variable for GIT to make use of this proxy command:

export GIT_PROXY_COMMAND=/Volumes/Repositories/explain-it-tools/proxy_command.sh

 

And now you can use git as you would without network restrictions:

git clone git://github.com/altercation/solarized.git

Autor: falko

a *nix nerd

  1. Thanks, cool article! I will try to use this in the future.

    For such cases I just used git’s HTTP transport instead of the native one. It can handle the HTTP proxy variables found in the environment.

Comments are closed.