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 git@github.com: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 git@github.com
ssh: connect to host github.com port 22: Connection timed out

$ # but this might work
$ ssh -T -p 443 git@ssh.github.com
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 git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.

$ git clone git@github.com: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) *** ** * ** ***

相关推荐
不爱学英文的码字机器1 天前
Git误操作急救手册大纲
git
A懿轩A1 天前
【2026 最新】Mac 电脑配置指南:Homebrew 安装换源 + Git 环境配置(保姆级教程)
git
切糕师学AI1 天前
Visual Studio Git 使用指南
git·elasticsearch·visual studio
徐小夕1 天前
借助AI,1周,0后端成本,我开源了一款Office预览SDK
前端·vue.js·github
蜜汁小强1 天前
Git Worktree:在不打断当前开发的情况下紧急修复生产问题
git
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-03-18)
ai·大模型·llm·github·ai教程
逛逛GitHub1 天前
硅谷大佬把自己 Claude Code 武器库给开源了,1 周就 2 万点赞。
github
星浩AI1 天前
清华团队开源!我给孩子制作了 AI 互动课堂,手把手教你给孩子做一个
人工智能·后端·github
宇宙realman_9991 天前
Git 本地版本控制极简使用笔记(Qt 项目专用)
笔记·git
坐吃山猪1 天前
OpenClaw02_GitHook使用
git·hook·openclaw