Git-over-SSH through Socks 5 Proxy on Windows
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:
- Git on Windows – http://code.google.com/p/msysgit/
- Connect.c – http://bent.latency.net/bent/darcs/goto-san-connect-1.85/src/connect.html
Then, you need a script that connects to the Socks 5 server. Like:
#!/bin/sh # Filename: /path/to/socks-gw.sh # 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:
#!/bin/sh # Filename: /path/to/socks-ssh.sh # This script opens an SSH connection through a SOCKS server ssh -o ProxyCommand="/path/to/socks-gw.sh %h %p" $@
Finally, another script that you need to source in the same Bash session you are going to use Git:
#!/bin/sh # Filename: /path/to/enable_socks5_proxy_for_git.sh # This script sets Git to use the SOCKS proxy export GIT_SSH="/path/to/socks-ssh.sh" export GIT_PROXY_COMMAND="/path/to/socks-gw.sh"
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.

about 1 month ago
Wow, I finally found this after a few hours of intensive search. Although the enable_socks5_proxy_for_git.sh didn’t work for me for some reason, but if I export the global vars manually with the other two scripts, it runs pretty well. Originally I tried many many times with some examples that could run on *nix system (like the one on github about “how to transparently clone from github with ssh tunnel”), I just can’t figure out how to adapt that on msysgit environment.
Your post definitely saved my day! Many Thanks.
about 1 month ago
I use those scripts on Windows-msysgit myself: I have every script in
"/c/bin/". It works as long as msysgit doesn’t have a bug.And in the last 2/3 months happened at least once that in, an update, the msysgit guys screwed the configuration. So, it’s not always something we can workaround.
Anyway, no prob