kex_exchange_identification: Connection closed by remote hostConnection closed by ::1 port 22

kex_exchange_identification: Connection closed by remote hostConnection closed by ::1 port 22

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Gb5Dn0oc-1659776217721)(../my_images/329196143531489095f966b40b2329f2.png)]

缘起
  • 拉代码仓库出错,还挺常见

https 错误原因:

fatal: unable to access ‘https://github.com/jing-zhi/go-sword-admin.git/’: SSL certificate problem: unable to get local issuer certificate

ssh 错误原因:

kex_exchange_identification: Connection closed by remote host
Connection closed by ::1 port 22
fatal: Could not read from remote repository.

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

jingz@jing-zhi- MINGW64 /d/sanyue_project/sanyue-框架
$ git clone https://github.com/jing-zhi/go-sword-admin.git
Cloning into 'go-sword-admin'...
fatal: unable to access 'https://github.com/jing-zhi/go-sword-admin.git/': SSL certificate problem: unable to get local issuer certificate

jingz@jing-zhi- MINGW64 /d/sanyue_project/sanyue-框架
$ git clone [email protected]:jing-zhi/go-sword-admin.git
Cloning into 'go-sword-admin'...
kex_exchange_identification: Connection closed by remote host
Connection closed by ::1 port 22
fatal: Could not read from remote repository.

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

推测原因之一:github的邮箱地址和git global的email不一样

git config --global user.email  "[email protected]" // 设置成和我在github账号一样的邮箱
$ ssh-keygen –t rsa –C "[email protected]"  // 重新生成key
结果——失败了,依旧报同样错

推测其他原因等…

$ ssh -T [email protected]

检查github公钥配置情况出错。

根据报错原因,推测可能是22端口把他关闭了,先检查一下22端口号是否开启
netstat -na

kex_exchange_identification: Connection closed by remote hostConnection closed by ::1 port 22_第1张图片

如图是开启的

真正原因

之前国内对github完全封死,造成DNS域名解析错误,即便翻外网进去也不能直接拉代码了。需要一点配置

然而我有个好兄弟给我解决了

  • C:\Windows\System32\drivers\etc
  • 在hosts中添加github的ip地址对应:140.82.112.3 github.com

kex_exchange_identification: Connection closed by remote hostConnection closed by ::1 port 22_第2张图片

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JNBz9Hwk-1659776217725)(../my_images/image-20220806165453670.png)]

你可能感兴趣的:(bug解决,github,git)