#!/bin/sh# Use socat to proxy git through an HTTP CONNECT firewall.# Useful if you are trying to clone git:// from inside a company.# Requires that the proxy allows CONNECT to port 9418.## Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run# chmod +x gitproxy# git config --global core.gitproxy gitproxy## More details at http://tinyurl.com/8xvpny# Configuration. Common proxy ports are 3128, 8123, 8000._proxy=proxy.yourcompany.com
_proxyport=3128
_proxyauth=username:password
exec socat STDIO PROXY:${_proxy}:$1:$2,proxyport=${_proxyport},proxyauth=${_proxyauth}
然后配置 git 使用这个代理, 在 ~/.gitconfig 文件里写入:
123
[core]gitproxy=gitproxy.sh for github.com
#man git-config 查看 core.gitproxy 部分,关于 for * 的说明
ssh -nNT -D 8119 remote.host
#This command starts a SOCKS v4 proxy listening on localhost, port 8119.
第二步: 创建一个新的 gitproxysocks.sh 脚本,并赋予可执行权限.
123456789
#!/bin/sh## Use socat to proxy git through a SOCKS proxy.# Useful if you are trying to clone git:// from inside a company.## See http://tinyurl.com/8xvpny for Emil Sit's original HTTP proxy script.# See http://tinyurl.com/45atuth for updated SOCKS version.## Configuration._proxy=localhost_proxyport=8119
execsocat STDIO SOCKS4:$_proxy:$1:$2,socksport=$_proxyport