Github 之 Connection timed out 的问题

最近push代码到github的时候出现了问题

$ git push origin master

ssh: connect to host github.com port 22: Operation timed out

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

经过google后找到了解决办法

先用如下命令进行测试

1
ssh -T -p 443 [email protected]

如果测试后出现下面类似的提示说明可以继续操作了

1
Hi userName! You've successfully authenticated, but GitHub does not provide shell access.

接下来编辑~/.ssh/config文件(没有则创建一个),然后加入下面的代码:

1
2
3
Host github.com 
Hostname ssh.github.com
Port 443

最后在进行测试下

1
ssh -T xx@xxx

如果有如下提示表示可以进行正常操作了

1
2
Warning: Permanently added the RSA host key for IP address '[192.30.253.122]:443' to the list of known hosts. 
Hi yourname! You've successfully authenticated, but GitHub does not provide shell access.