Github出现 ssh operation timed out

xiaoxiao2021-02-28  120

这两天在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文件,使其失效。

转载请注明原文地址: https://www.6miu.com/read-1950050.html

最新回复(0)