Introductory

Due to the mess as well as uneven on the internet,I decide to collect effective and efficient methods to address disgusting problens.
I am pleasure to accept everyone of you precious opinions.

hexo deploy 上传报错

1
connect to host github.com port 22: Connection refused
1
2
3
4
5
Error: Spawn failed     
at ChildProcess.<anonymous> (D:\Blog\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:524:28)
at cp.emit (D:\Blog\node_modules\cross-spawn\lib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:293:12)

首先说明

当hexo发生错误时,应该首先看出错的原因(第一栏代码),而非hexo出错的位置(第二栏代码)。笔者认为在不改动系统文件的情况下,不必去排查系统文件错误。

意图

ssh: connect to host github.com port 22: Connection refused这个错误提示的是连接github.com的22端口被拒绝了。

解决方法

使用GitHub的443端口
22端口可能被防火墙屏蔽了,可以尝试连接GitHub的443端口。

  1. 这个方案有效的前提是:执行命令ssh -T -p 443 git@ssh.github.com后不再提示connection refused。
  2. 打开文件资源管理器:C:->用户->用户名->.ssh
  3. 新建config文件(无后缀)
  4. 添加
1
2
3
Host github.com
Hostname ssh.github.com
Port 443
  1. 修改完config文件后,使用ssh -T git@github.com来测试和GitHub的网络通信是否正常,如果提示Hi xxxxx! You've successfully authenticated, but GitHub does notprovide shell access. 就表示一切正常了。