当前位置:   article > 正文

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

github connection

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
    Hostname ssh.github.com
    Port 443
    User git
  • 1
  • 2
  • 3
  • 4


在这里插入图片描述

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

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

  1. 设置成功

出现如下即可

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

在这里插入图片描述

方法三

参考:kex_exchange_identification: Connection closed by remote host


我是通过方法一配合方法二解决搞定的,但也时常因为

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/982367
推荐阅读
相关标签