首先,报错信息
1
2
3
4
|
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.
|
这可能是防火墙导致的,解决方法参考官方帮助文档
https://help.github.com/en/github/authenticating-to-github/using-ssh-over-the-https-port
具体的解决步骤
- 先测试可用性
1
|
ssh -T -p 443 git@ssh.github.com
|
提示如下证明可用
1
2
|
Hi username! You’ve successfully authenticated, but GitHub does not
provide shell access.
|
- 然后编辑~/.ssh/config 文件,如果没有config文件的话就直接vim ~/.ssh/config加入如下内容
1
2
3
|
Host github.com
Hostname ssh.github.com
Port 443
|
- 再次测试
提示如下即可用
1
|
Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.
|
问题解决!
奇妙的是我把它更改为443端口后再更改回22端口,居然不报错了,尚不清楚为什么,如果有人有新的发现,请给我留言,非常感谢(已更正,并不能- -!)