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.
相关推荐
xuhe29 小时前
Claude Code配合Astro + GitHub Pages:为 sharelatex-ce 打造现代化的开源项目宣传页
linux·git·docker·github·浏览器·overleaf
西门吹-禅10 小时前
git 使用
git
铁甲前沿15 小时前
一个月玩转MQTT(篇四:移远EC200U模块MQTT连接测试)
mqtt·github·emqx·mqttx·移远ec200u
前路不黑暗@17 小时前
Java项目:Java脚手架项目的模板服务和网关服务的实现(三)
java·开发语言·spring boot·git·学习·spring cloud·maven
贡献者手册18 小时前
当 AI 写代码的速度超过了你提交的速度:为何你需要一款“流式” Git 管理器?
人工智能·git
琛説20 小时前
⚡PitchPPT:将PPT导出为高清全图PPT,并控制PPT文件大小在固定MB/GB以内【解析算法原理 · 作者谈】
windows·python·算法·github·powerpoint
NGC_661120 小时前
idea中使用git
java·git·intellij-idea
承渊政道20 小时前
Linux系统学习【深入剖析Git的原理和使用(上)】
linux·服务器·git·学习
阿里嘎多学长21 小时前
2026-02-14 GitHub 热点项目精选
开发语言·程序员·github·代码托管