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 代理(推荐)

Host github.com
    HostName ssh.github.com
    User git
    Port 443
    ProxyCommand nc -X connect -x 127.0.0.1:7890 %h %p
  • -X connect:使用 HTTP CONNECT 方法
  • -x 指定代理地址

参考:

SOCKS5 代理

Host github.com
    User git
    ProxyCommand nc -X 5 -x 127.0.0.1:7891 %h %p
  • -X 5:使用 SOCKS5 协议

参考:让你的 SSH 通过 HTTP 代理或者 SOCKS5 代理 | kuokuo.io

posted @ 2024-11-20 18:18  Undefined443  阅读(864)  评论(0)    收藏  举报