github clone失败问题解决

问题描述

  1. git 克隆 github 仓库,表现如下
$ git clone git@github.com:CANopenNode/CANopenNode.git
Cloning into 'CANopenNode'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

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

  1. 参考github上的一个帖子,配置ssh的系统代理如下
    github上解决该问题的帖子
    win11配置:在.ssh目录下新建文件config, .ssh/config 内容如下:
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 22
ProxyCommand connect -S 127.0.0.1:7890 %h %p
  1. 重新克隆第一步的仓库,继续报错
$ git clone git@github.com:CANopenNode/CANopenNode.git
Cloning into 'CANopenNode'...
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
fatal: Could not read from remote repository.

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

  1. 继续搜索该问题,发现另一篇解决问题的帖子
    原贴
    修改 .ssh/config的内容如下
Host github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  ProxyCommand connect.exe -S 127.0.0.1:7890 -a none %h %p

Host ssh.github.com
  User git
  Port 443
  Hostname ssh.github.com
  IdentityFile ~/.ssh/id_rsa
  TCPKeepAlive yes
  ProxyCommand connect.exe -S 127.0.0.1:7890 -a none %h %p
  1. 重新克隆,问题得到解决,github仓库可以正常克隆,但是无法Ping github的问题仍未解决

问题分析

  1. 猜想可能是因为代理配置的问题导致和github的通信出现错误,原因不清楚
  2. 在终端ping github的时候发现解析出来的地址是20.205.243.166,使用Ip查询网站发现该ip在香港,猜想可能是因为DNS解析的问题导致解析出来的github地址无法访问,不过这个问题不重要,github能够克隆就行
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值