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