zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

sshGitHub错误连接 to quot com 22
2023-09-27 14:24:55 时间

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文本,内容如下:

Host github.com
User YourEmail@163.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

其中User为登录github的账号名称。
再次执行”ssh -T git@github.com”时,会出现提示如下,回车”yes”即可。
这里写图片描述
这时验证就可以通过。
这里写图片描述