github.com port 22: Connection timed out

背景

  • 今天突然用ssh方式 pull GitHub的项目报github.com port 22: Connection timed out
 $ git clone git@github.com:1030907690/dayAndNightAndroidCustomServerPy.git
Cloning into 'dayAndNightAndroidCustomServerPy'...
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.

在这里插入图片描述

  • 这个大概是公司网络把访问出去22端口给屏蔽了,我telnet也不通。

解决方案

  • GitHub允许使用443端口,下面改成走443端口。
  • 先检查走443端口能否行得通。
ssh -T -p 443 git@ssh.github.com
  • 确认有successful提示,如下。
 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])? yes
Warning: Permanently added '[ssh.github.com]:443' (ED25519) to the list of known hosts.
Hi 1030907690! You've successfully authenticated, but GitHub does not provide shell access.

在这里插入图片描述

  • 确认可以,下一步编辑文件
vim ~/.ssh/config
  • 加入以下代码
Host github.com
Hostname ssh.github.com
Port 443
  • 测试是否成功ssh -T git@github.com,如下所示
    在这里插入图片描述

  • 然后拉取项目就可以了,如下所示
    在这里插入图片描述

参考

posted on 2022-05-27 08:47  愤怒的苹果ext  阅读(337)  评论(0编辑  收藏  举报

导航