这两天在mac上使用github出现了问题,git push命令一直未响应,直到超时出现了如下的错误
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的查询,参考了该博客的内容,可能的原因是ssh默认使用的22端口出现了问题,更换端口可以解决该问题。流程如下:
修改
~/.ssh/config文件在修改config文件如下:
Host github.com User xxx@yy.com #注册github的邮箱 Hostname ssh.github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa # 公钥的存放位置 Port 443重新使用SSH测试连接
ssh -T git@github.com Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.如果在这步中要求接受或者拒绝远程主机的公钥,输入yes即可。
完成了上面的步骤,再使用git push命令就没有问题了。
如果在443端口也出现了timeout的问题,则可以尝试切换回22端口再尝试,即使用mv命令重命名~/.ssh/config文件,使其失效。
本文介绍了在Mac上使用GitHub遇到SSH连接超时的问题及解决方案。通过修改SSH配置文件指向不同的端口,如从默认的22端口更改为443端口,并重新建立SSH连接,最终成功解决了git push命令的超时问题。
3258

被折叠的 条评论
为什么被折叠?



