Could not read from remote repository - 记:一次SSH代理导致的异常

缘由

周一刚上班,打开命令行进行git pull时,报错;难道是我打开的方式不对?换个命令,再次git fetch,还是报错;???(满头雾水)
昨天还好好的呀 难道是我ssh 密钥出问题了?

$ git pull
kex_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

$ git fetch
kex_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决

搜了一圈,大多数都是说SSH配置出问题了,让重新配置一下SSH,感觉不对劲,终于发现一位大佬的文章, 解决步骤如下:

使用SSH调试模式输出一下Log

$ ssh -v git@github.com
OpenSSH_8.1p1, LibreSSL 2.7.3
...
debug1: Executing proxy command: exec nc -X 5 -x 127.0.0.1:1080 github.com 22
...
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: kex_exchange_identification: banner line 0: error = 0 61
kex_exchange_identification: Connection closed by remote host

关键信息就是Executing proxy command: exec nc -X 5 -x 127.0.0.1:1080 github.com 22, 原来是我之前有配置过命令行git clone代理加速,然后代理挂掉了,导致服务异常。

注释命令行代理配置

编辑~/.ssh/config文件,注释其中的代理配置

参考文章

文章.IceIceBear