git clone遇到错误 fatal: unable to access ‘http://github.com/xxx‘: Failed to connect to github.com port

本文详细介绍了如何解决gitclone过程中出现的连接错误,包括配置git的user.name和user.email,生成SSH密钥,以及如何在GitHub上添加公钥,确保远程仓库的正确访问权限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

git clone出错 fatal: unable to access 'http://github.com/xxx': Failed to connect to github.com port


  1. 使用命令 git config --list查看git的配置信息,这里面可以看到user.name 还有 user.email 如果没有的话不要慌,看下一步;
     
  2. git config --global user.name "github_name"
    git config --blobal user.email "email"

上面的github_name填github的用户名,email则是github的email

  1. 然后使用指令ssh-keygen -t rsa -C "github_name"
     
  2. 在github上的设置中填写公钥信息SSH key,需要自行生成并填入,具体怎么查看公钥,使用命令行 cat /root/.ssh/id_rsa.pub
    在这里插入图片描述
     
  3. 使用命令行 cat /root/.ssh/id_rsa.pub后将得到的 ssh-rsa xxx……这一干内容复制下来(结尾的用户名不用复制)粘贴到github的 New SSH key上;
    在这里插入图片描述
    在这里插入图片描述

注意:第3、4、5步还可以解决Could not read from remote repository.Please make sure you have the correct access rights的问题

  1. 检测是否可用,使用命令 ssh -T git@github.com,运气好的人可能就成功了,若没报错就可以结束了,出问题就继续往下看;
    在这里插入图片描述
     
  2. 修改config文件 vim ~/.ssh/config,在里面添加以下内容:(记得保存退出)

Host github.com
Hostname ssh.github.com
Port 443

  1. 然后使用命令 ssh -T git@github.com发现可以正常了。

  2. 最后再正常git clone git clone git@github.com/xxx.git就可以了(一定要把目的代码fork到自己的Repositories里)。
    在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值