解决 ssh: connect to host github.com port 22: Connection timed out error
解决 ‘ssh: connect to host github.com port 22: Connection timed out’ error
问题复现
MacOS Ventura 13.1
生成ssh key ,并将 key 添加到 github keys
使用 ssh clone 仓库
$ git clone [email protected]: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.
测试连接也 timeout
$ ssh -T [email protected]
ssh: connect to host github.com port 22: Connection timed out
但是可以 ping 通 github.com
test 指定 443 可以成功
$ ssh -T -p 443 [email protected]
Hi xxxx! You've successfully authenticated,
but GitHub does not provide shell access.
如何解决
覆盖 ssh 的配置
vim ~/.ssh/config
添加以下内容
Host github.com
Hostname ssh.github.com
Port 443
重新测试一下
$ ssh -T [email protected]
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.
clone 仓库
$ git clone [email protected]: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