解决:github.com port 22 timeout

错误:

ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

无论是push、pull还是clone均无法操作。

很大可能的原因是防火墙屏蔽了22端口。因为是timeout嘛。


解决方案:
编辑或者新建~/.ssh/config,添加:

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

这段配置的意思是:所有访问 github.com 的 SSH 连接,实际都转向 ssh.github.com 的 443 端口。这正是 GitHub 官方提供的通过 443 端口使用 SSH 的方案。 如果你使用的是其他 Git 托管服务(如 GitLab),需要查询其官方文档是否支持以及对应的 SSH over HTTPS 的主机名是什么。

无论是Windows,或者是Linux,都可以。

posted @ 2025-08-28 19:11  QMazon  阅读(27)  评论(0)    收藏  举报