为 git设置代理
一、针对 http
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
git config --global --unset http.proxy git config --global --unset https.proxy
二、针对 ssh
方法一:使用 proxychains 将 ssh 转换成 http
1.安装 proxychains:
yaourt -S proxychains
2.修改 /etc/proxychains.conf 文件:
注释掉下面的两行
proxy_dns
socks4 127.0.0.1 9050
末尾添加一行
socks5 127.0.0.1 1080
3.使用方法
proxychains git clone git@github.com:lemos1235/TamakosBot.git
方法二:配置 .ssh/config
Host github.com
User git
ProxyCommand nc -x localhost:7890 %h %p
或者
Host github.com
User git
Port 22
Hostname github.com
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
ProxyCommand /usr/local/bin/ncat --proxy 127.0.0.1:7890 --proxy-type socks5 %h %p