github连接报"ssh: connect to host github.com port 22: Connection timed out"错误

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


注意选择url下载链接的时候要选择ssh类型的链接,要选择ssh类型的链接,要选择ssh类型的链接
呜呜呜浪费我两小时

1.异常

在连接github时,执行”ssh -T git@github.com” 命令时,出现

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

2.解决

在存放公钥私钥(id_rsa和id_rsa.pub)的文件里,新建config文本,内容如下:

第一步:打开终端并打开存放ssh的目录

cd ~/.ssh

ls

查看是否存在这些文件 若不存在,则可能是ssh没配置对,首先需要配置ssh(自行百度)很简单
若存在则在继续在终端输入以下命令新建一个文件
vim config

接着输入下面内容

Host github.com
User 注册github的邮箱
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

最后:wq退出编辑即可
接着再执行

ssh -T git@github.com
1
出现提示回车yes即可

验证就能顺利通过了

总结自:https://blog.csdn.net/vosang/article/details/50499300

posted @ 2022-02-20 12:55  晚觉入海  阅读(4754)  评论(0编辑  收藏  举报
Document