Git问题:git拉取/推送github代码出现Connection closed by问题

我会带着你远行 2024-04-27 15:45 178阅读 0赞

git拉取/推送github代码出现Connection closed by问题,这个问题出现过几次,还是总结一下

目录

  • 问题
  • 原因
  • 解决
    • 方法一
    • 方法二
    • 方法三
  • 最后

问题

使用git去拉取github代码的时候,出现了如下问题

Connection closed by ip port
致命错误:无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。

Connection closed by ip port
fatal : Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

在这里插入图片描述

原因

访问 GitHub 可能会受到防火墙(Great Firewall)的限制,导致无法正常读取代码。这可能是导致在拉取 GitHub 代码时遇到问题的原因之一,当然也最有可能的就是这个情况了。

解决

方法一

切换梯子的节点解决

  • 亲测有效:但是需要注意,可能操作一次切换不一定会生效,需要多次切换才会生效

方法二

通过配置使git走https协议解决

主要是修改 ~/.ssh/config 文件

  1. 检查 cat ~/.ssh/config 文件当前配置
    在这里插入图片描述
  2. 编辑 vim ~/.ssh/config 增加配置如下

    Host github.com

    1. Hostname ssh.github.com
    2. Port 443
    3. User git


在这里插入图片描述

  1. 测试验证 ssh -T git@github.com

    ssh -T git@github.com

出现下图情况,选择yes即可
在这里插入图片描述

  1. 设置成功

出现如下即可

  1. Warning: Permanently added '[ssh.github.com]:443' (ED25519) to the list of known hosts.
  2. Hi **! You've successfully authenticated, but GitHub does not provide shell access.

在这里插入图片描述

方法三

参考:kex_exchange_identification: Connection closed by remote host


我是通过方法一配合方法二解决搞定的,但也时常因为?的不稳定影响开发!


最后

  • 好看的灵魂千篇一律,有趣的鲲志一百六七!
  • 如果觉得文章还不错的话,可以点赞+收藏+关注 支持一下,鲲志的主页 还有很多有趣的文章,欢迎小伙伴们前去点评
  • 如果有什么需要改进的地方还请大佬指出❌

在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,178人围观)

还没有评论,来说两句吧...

相关阅读