Github拉取项目报错解决

前言

昨天在拉取github上面的项目报错了,有好几个月没用github了,命令如下:

bash 复制代码
git clone git@github.com:zhszstudy/git-test.git

报错信息:

bash 复制代码
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.

我重新设置github上的ssh key,梯子也开了还是报这个错,换成https链接拉取也报错,查阅资料发现,此错误信息为不能通过 22 端口连接到 GitHub

解决方法

  1. 执行以下命令:
bash 复制代码
ssh -T git@github.com

如果出现连接超时就意味着不能通过22端口连接:

bash 复制代码
ssh: connect to host github.com port 22: Connection timed out
  1. 将 SSH 连接的端口更改为 443:
bash 复制代码
ssh -T -p 443 git@ssh.github.com

出现以下信息,表示通过 443 端口成功进行了身份验证,但 GitHub 不提供 shell 访问权限:

bash 复制代码
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

如果出现以下信息,则需要回复yes,如果输出上面的信息表示成功:

bash 复制代码
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Host key verification failed.
  1. 在密钥目录下新建文件config,编写配置覆盖 SSH 设置:
bash 复制代码
Host github.com
  Hostname ssh.github.com
  Port 443
  1. 重新执行以下命令:
bash 复制代码
ssh -T git@github.com

出现以下信息表示成功:

bash 复制代码
Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
  1. 重新拉取项目,可以看到已经拉取成功了:
bash 复制代码
$ git clone git@github.com:zhszstudy/git-test.git
Cloning into 'git-test'...
remote: Enumerating objects: 118, done.
remote: Counting objects: 100% (118/118), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 118 (delta 12), reused 109 (delta 11), pack-reused 0 (from 0)
Receiving objects: 100% (118/118), 7.90 KiB | 476.00 KiB/s, done.
Resolving deltas: 100% (12/12), done.
相关推荐
Phil3236 小时前
开源一个 Windows 实时面试助手:听译、置顶提词、按需生成英文稿
面试·github
千纸鹤1906 小时前
Kafka vs RabbitMQ:在秒杀场景下如何选型与
github
lingran__7 小时前
Git 完全指南(二):分支管理
git·分支管理·版本控制·团队协作·多人开发·git flow
左青7 小时前
零 token 发布 npm 包:Trusted Publisher + OIDC 实战(附五个真实的坑)
github
编程快车7 小时前
GitHub 从入门到精通(精炼版):30 分钟跑通建仓、提交与协作
github
WebInfra8 小时前
Rslib 1.0 正式发布:面向多场景的 JavaScript 库开发工具
前端·javascript·github
Tongsr8 小时前
别只混淆代码:用 Kaleido 加固整个 Android Release AAB
前端·算法·github
敢敢是只喵i8 小时前
WorkBuddy 开放生态之后,AI 真正进入业务系统还缺什么?
github
必须会一定会8 小时前
Agent Handoff v0.6.0 跨电脑同步:Git、EVENTS.jsonl、CONTEXT.md 使用方法
人工智能·git·ai编程
泡海椒9 小时前
响应自动序列化:JSON 响应一键转 Java 实体对象,JQuick-Curl 第三方接口调用不再手动解析
后端·github