git配置socks5代理Failed to receive SOCKS5 connect request ack.

1,012 阅读1分钟

需要下github上的源码时,如果不配置代理会报Connection refused错误,道理都懂的

git clone https://github.com/woodada/ioutil.git

正克隆到 'ioutil'...

fatal: unable to access 'https://github.com/woodada/ioutil.git/': Failed connect to github.com:443; Connection refused

所以git配置sock5代理

git config --global http.proxy socks5://192.168.2.4:1080
git config --list
http.proxy=socks5://192.168.2.4:1080

再次尝试,报Failed to receive SOCKS5 connect request ack错误

[root@localhost tmp]# git clone https://github.com/woodada/ioutil.git
正克隆到 'ioutil'...
fatal: unable to access 'https://github.com/woodada/ioutil.git/': Failed to receive SOCKS5 connect request ack.

解决办法,配置sock5h代理,即原sock5前缀改为sock5h

git config --global http.proxy socks5h://192.168.2.4:1080
git config --list
http.proxy=socks5h://192.168.2.4:1080

这样就能成功下载了

sock5、socks5h、sock4、sock4a有什么区别呢?

在代理配置字符串里, socks5h:// 和 socks4a:// 代表着在代理服务端进行域名解析。

socks5:// and socks4:// 则是在本地进行解析。

另外,socks4a:// 是SOCKS4协议扩展中的一部分,是代理协议本身支持的。