Git-over-SSH through Socks 5 Proxy on Windows

  • git • script • personal • work • it • tunnelling • windows • socks5 • proxy • english • utility • bash • ssh
  • 190 words

Because of my work, I use crappy M$ Windows in my office. And we are behind a bidirectional firewall.

So, how do you do if you need to pull/push code with Git-over-SSH in this scenario? You need a Socks 5 that passes the firewall, and some scripting.

First, you need to install:

Then, you need a script that connects to the Socks 5 server. Like: [sourcecode lang='bash']


Filename: /path/to/

This script connects to a SOCKS proxy using Connect.c

/path/to/connect.exe -S your.socks5.server:1080 $@ ```

A script that opens an SSH connection using the connection opened by the previous script: [sourcecode lang='bash']


Filename: /path/to/

This script opens an SSH connection through a SOCKS server

ssh -o ProxyCommand="/path/to/ %h %p" $@ ```

Finally, another script that you need to source in the same Bash session you are going to use Git: [sourcecode lang='bash']


Filename: /path/to/

This script sets Git to use the SOCKS proxy

export GITSSH="/path/to/" export GITPROXY_COMMAND="/path/to/" ```

Again, don't forget to source this script before using Git.

Thanks to ThreeBytesFull, from which I re-adapted the scripts to work on Windows.

comments powered by Disqus