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 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==)]编辑

如图是开启的

真正原因

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

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

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

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

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

  • 13
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
kex_exchange_identification: Connection closed by remote host Connection closed by 127.0.0.1 port 22是一个错误消息,它表示在连接远程主机时发生了连接关闭的情况。这个错误通常出现在通过SSH协议连接到远程主机时。引用和引用中的错误消息都包含了这个错误。根据引用中的输出信息,我们可以看到连接建立成功,但是在交换密钥标识时出现了连接关闭的情况。这可能是由于网络问题、权限问题或存储库不存在等原因引起的。 要解决这个问题,你可以尝试以下几个步骤: 1. 检查网络连接:确保你的网络连接正常,没有阻塞或限制SSH连接的问题。 2. 检查权限:确保你有正确的访问权限,包括使用正确的用户名和密码、公钥认证或访问令牌。 3. 检查存储库是否存在:确认你正在连接的存储库存在并且你有权限访问它。 4. 使用不同的协议和端口:尝试使用不同的协议(如HTTPS)或不同的端口来连接远程主机。 5. 检查SSH配置:检查你的SSH配置文件是否正确,并确保没有任何冲突或错误的配置。 根据你提供的信息,由于错误消息中显示的远程主机IP地址是127.0.0.1,这个IP地址代表本地主机。可能有一些本地配置问题导致连接关闭。你可以尝试检查和修复本地的SSH配置和网络设置。如果问题仍然存在,建议查阅相关的SSH文档或咨询技术支持以获取进一步的帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Git通过SSH拉取报错kex_exchange_identification](https://blog.csdn.net/qq_43657722/article/details/127388152)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [kex_exchange_identification: Connection closed by remote host Connection closed by 198.18.0.114 port](https://blog.csdn.net/a12355556/article/details/127691245)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不之道

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值