git 报错 Connection reset by 20.205.243.160 port 22 解决
问题描述
在某天愉快地拉取代码时突然发现拉不了了:
$ git pull
kex_exchange_identification: read: Connection reset by peer
Connection reset by 20.205.243.160 port 22
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
这是由于 git pull 时 SSH 连接被 GFW 阻断导致的。
解决方法:代理 SSH 连接。
HTTP 代理(推荐)
HTTP 代理需要安装 connect 或 corkscrew。
connect
需要安装 connect:
# macOS
brew install connect
# Ubuntu / Debian
sudo apt install connect-proxy
编辑 ~/.ssh/config:
Host github.com
HostName ssh.github.com
User git
Port 443
ProxyCommand connect -H 127.0.0.1:7890 %h %p
corkscrew
需要安装 corkscrew:
# macOS
brew install corkscrew
# Ubuntu / Debian
sudo apt install corkscrew
编辑 ~/.ssh/config:
Host github.com
HostName ssh.github.com
User git
Port 443
ProxyCommand corkscrew 127.0.0.1 7890 %h %p
参考:
SOCKS5 代理
需要安装 OpenBSD Netcat:
sudo apt install netcat-openbsd
编辑 ~/.ssh/config:
Host github.com
HostName github.com
User git
ProxyCommand nc -x 127.0.0.1:1080 -X 5 %h %p
-x指定代理地址-X 5指定 SOCKS5 协议

浙公网安备 33010602011771号