解决-git连接github超时问题Connection timed out


亲测有效解决ssh: connect to host github.com port 22: Connection timed out问题

  • 百度一直说的密钥问题,修改了依然没解决,后来发现添加几行代码到Git的位置就好了,话不多说上解决方案。

1.问题

运行hexo g -d就报如下错误

On branch master
nothing to commit, working tree clean
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL {
  err: Error: Spawn failed
      at ChildProcess.<anonymous> (D:\hexo\GitHub\blog\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:51:21)
      at ChildProcess.emit (events.js:315:20)
      at ChildProcess.cp.emit (D:\hexo\GitHub\blog\node_modules\cross-spawn\lib\enoent.js:34:29)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12) {
    code: 128
  }
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.htmlxxxxxxxxxx On branch masternothing to commit, working tree cleanssh: connect to host github.com port 22: Connection timed outfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.FATAL {  err: Error: Spawn failed      at ChildProcess.<anonymous> (D:\hexo\GitHub\blog\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:51:21)      at ChildProcess.emit (events.js:315:20)      at ChildProcess.cp.emit (D:\hexo\GitHub\blog\node_modules\cross-spawn\lib\enoent.js:34:29)      at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12) {    code: 128  }} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.htmlhexo g -djava

2.分析

当出现:ssh: connect to host github.com port 22: Connection timed out时,这表明连接超时

3.解决方法

连接超时,首先找到git的安装目录,找到/etc/ssh/ssh_config文件,使用记事本打开它。

把如下内容复制到ssh_config文件的末尾处:并记得保存。

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

添加完成后如下图

再输入hexo g -d,完美解决。希望能帮到你


文章作者: 浅 悦
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 浅 悦 !
评论
 上一篇
解决-github.com** 的响应时间过长的问题 解决-github.com** 的响应时间过长的问题
1.问题 当打开自己的Github博客时,显示无法访问此网站(可以尝试更换网络,比如现在用的是联通网络,更换为电信或者移动网络)。
2020-12-19
下一篇 
Hexo博客matery主题 Hexo博客matery主题
这是一个采用 Material Design 和响应式设计的 Hexo 博客主题。 特性 简单漂亮,文章内容美观易读 Material Design 设计 响应式设计,博客在桌面端、平板、手机等设备上均能很好的展现 首页轮播文章及每天动
2020-12-16
  目录