GitHub 异常——无法连接22端口:Connection timed out

GitHub 异常------无法连接22端口:Connection timed out


问题描述

  • 正常配置并使用使用SSH方式,使用以下命令git clonegit pullgit push,报错如下:

    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.

原因分析:

  • 表明SSH连接在尝试通过22端口连接到远程服务器时超时。这可能是由于网络环境、防火墙设置或代理配置等原因导致的(很可能端口22被防火墙或提供商阻止了)。

解决方案:

bash 复制代码
$ git clone [email protected]:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

$ # This should also timeout
$ ssh -T [email protected]
ssh: connect to host github.com port 22: Connection timed out

$ # but this might work
$ ssh -T -p 443 [email protected]
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

$ # Override SSH settings

$ vim ~/.ssh/config

# Add section below to it
Host github.com
  Hostname ssh.github.com
  Port 443
  
$ ssh -T [email protected]
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.

$ git clone [email protected]:xxxxxx/xxxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 15 (delta 0), reused 15 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), 22.90 KiB | 4.58 MiB/s, done.

参考

1\]. [在 HTTPS 端口使用 SSH](https://docs.github.com/zh/authentication/troubleshooting-ssh/using-ssh-over-the-https-port) \[2\]. [Solution for 'ssh: connect to host github.com port 22: Connection timed out' error](https://gist.github.com/Tamal/1cc77f88ef3e900aeae65f0e5e504794) *** ** * ** ***

相关推荐
qianmoQ1 小时前
GitHub 趋势日报 (2025年06月08日)
github
Aisanyi4 小时前
【鸿蒙开发从入门到放弃】新建项目,并接入Git
github·harmonyos
今夕节度使5 小时前
通过 VS Code 连接 GitLab 并上传项目
git·elasticsearch·gitlab
陈 洪 伟6 小时前
复习Git命令、Git命令使用流程、VSCode+Git插件管理工程源码
git
百锦再8 小时前
Git 使用大全:从入门到精通
git·version·版本·代码·分支·code·clone
阿群的AI工作室8 小时前
新手必看喂饭级教程🔥原来这样用SSH推代码到GitHub才对!
github
中微子9 小时前
📝 终极Git Commit Message规范指南:写出专业级提交记录
git·github
小华同学ai9 小时前
真香,Cursor懂的都懂(学习用哈),22.5k一键重置Cursor试用限制!被全网疯狂收藏!
前端·后端·github
Android洋芋9 小时前
Steam++开发逻辑详解:从零到一的实战指南
后端·github