ssh: connect to host github.com port 22: Connection timed out

  1. 原因可能是端口被占用
  2. 在 ~/.ssh目录下创建个文件名为config的文件
$ touch config
  1. 填写如下内容并保存
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443
  1. 测试
$ ssh -T git@github.com
The authenticity of host '[ssh.github.com]:443 ([192.30.252.1]:443)' can't be established.
RSA key fingerprint is SHA256:nThARLviKw6E5SYbg6kXUpJWGl7E1IGOCspRomTxdC8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[ssh.github.com]:443,[192.30.252.1]:443' (RSA) to the list of known hosts.
Hi [your name]! You've successfully authenticated, but GitHub does not provide shell access.
# 虽然有个警告,这个GitHub上有人说这个只要IP是在192.30.252.0到192.30.255.255之间的话是没关系的。
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容