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
,如下所示
-
然后拉取项目就可以了,如下所示