当git pull或push时经常会遇到Could not read from remote repository
的报错,尤其是在启用Clash等代理软件后
# git push
kex_exchange_identification: Connection closed by remote host
Connection closed by 20.205.243.166 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
此时我们可以通过配置SSH代理来保障网络通畅,添加~/.ssh/config
文件,配置如下内容
# cat ~/.ssh/config
Host github.com
User git
Hostname github.com
Port 22
ProxyCommand nc -v -x localhost:7890 %h %p
ProxyCommand依赖nc,服务器上需要提前安装nc
# apt-get install ncat