clone github仓库时老是提示22端口超时,如下:

$ git clone [email protected]:xtod/yuwang.git
Cloning into 'yuwang'...
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.

还提示是否对该仓库具有访问权或者仓库是否存在,这不废话么,我肯定确认。

于是试着ssh -T了一下,看能不能访问,但提示的还是22端口超时

$ ssh -T [email protected]
ssh: connect to host github.com port 22: Connection timed out

现在来看应该是访问问题,在此把访问端口改为443吧,不用22了,编辑~/.ssh/config写入如下内容:

Host github.com
HostName ssh.github.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519

然后再ssh -T试一下

$ ssh -T [email protected]
Hi xtod! You've successfully authenticated, but GitHub does not provide shell access.

好了,可以正常使用了。