以下是对我有效的相当简单的解决方案:
问题
$ git clone git@github.com: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.
这也应该超时
$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
这可能有效
$ ssh -T -p 443 git@ssh.github.com
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 git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.
现在尝试克隆(应该可以工作)
$ git clone git@github.com: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
Receiving objects: 100% (15/15), 22.90 KiB | 4.58 MiB/s, done.
参考文献: 这里 => 使用端口443来使用HTTPS
.git/config
文件,确保一切都是正确的。对我来说,它的set-url和origin值是错误的。 - mixdev