SSH Connection Reset by Github

今天起来敲代码,敲完之后发现无法推送至 Github

提示连接被重置、无法读取远程仓库、确认是否有正确的访问权限、确认仓库是否存在。

1
2
3
4
5
6
$ git push
Connection reset 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 -T [email protected] 检测,同样提示连接被重置。猜测是网络问题,尝试使用环境变量 *_PROXY 依然失败。

1
2
$ ssh -T [email protected]
Connection reset by 20.205.243.166 port 22

以此为关键词进行检索,找到了 https://zhuanlan.zhihu.com/p/690536358 ,根据这篇文章对 ~/.ssh/config 进行配置:

1
2
3
4
5
6
7
8
9
# ~/.ssh/config

Host github.com
   port 22
   User git
   HostName github.com
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/id_ed25519
   ProxyCommand connect -S 127.0.0.1:114514 -a none %h %p

增加 ProxyCommand 项后,问题消失,又可以顺利地推送代码了。

1
2
$ ssh -T [email protected]
Hi LIXX.org! You've successfully authenticated, but GitHub does not provide shell access.
Built with Hugo
Theme Stack designed by Jimmy