當(dāng)git pull或push時經(jīng)常會遇到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代理來保障網(wǎng)絡(luò)通暢,添加~/.ssh/config文件,配置如下內(nèi)容
# cat ~/.ssh/config
Host github.com
User git
Hostname github.com
Port 22
ProxyCommand nc -v -x localhost:7890 %h %p
ProxyCommand依賴nc,服務(wù)器上需要提前安裝nc
# apt-get install ncat