kex_exchange_identification: Connection closed by remote hostConnection closed by ::1 port 22
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Gb5Dn0oc-1659776217721)(../my_images/329196143531489095f966b40b2329f2.png)]](https://img-blog.csdnimg.cn/fe27b34563c34dc0bde3f333603ce589.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 git@github.com: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 "jingzhi736728@163.com" // 设置成和我在github账号一样的邮箱
$ ssh-keygen –t rsa –C "jingzhi736728@163.com" // 重新生成key
结果——失败了,依旧报同样错
推测其他原因等…
$ ssh -T git@github.com
检查github公钥配置情况出错。
根据报错原因,推测可能是22端口把他关闭了,先检查一下22端口号是否开启
netstat -na
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AAyQ9vgN-1659776217723)(../my_images/9809f9f1450e4d6e8f271224b993700a.png)][外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vKpYETAd-1659776217724)(data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==)]编辑](https://img-blog.csdnimg.cn/9f0091ac46ce480daafb0cb80ae3817a.png)
如图是开启的
真正原因
之前国内对github完全封死,造成DNS域名解析错误,即便翻外网进去也不能直接拉代码了。需要一点配置
然而我有个好兄弟给我解决了
- C:\Windows\System32\drivers\etc
- 在hosts中添加github的ip地址对应:140.82.112.3 github.com
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-buwxpyM7-1659776217724)(../my_images/image-20220806165447742.png)]](https://img-blog.csdnimg.cn/993c354ab50e47089724143434bf970c.png)
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JNBz9Hwk-1659776217725)(../my_images/image-20220806165453670.png)]](https://img-blog.csdnimg.cn/9f7cbd8c043f40adbf099ebff3ae4d9d.png)
本文含有隐藏内容,请 开通VIP 后查看