平时写完博客都是使用如下的命令来生成并部署,g 代表生成模板,d 代表部署到 GitHub。
hexo g -d
以前这命令都用的好好的,今天突然报出了如下错误。看了下就是 ssh 通过 22 端口连接不上。
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 Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
at ChildProcess.<anonymous> (D:\Users\zhl\WorkSpace\blog\node_modules\hexo-util\lib\spawn.js:52:19)
at ChildProcess.emit (events.js:210:5)
at ChildProcess.cp.emit (D:\Users\zhl\WorkSpace\blog\node_modules\cross-spawn\lib\enoent.js:40:29)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
我们通过命令行连接 GitHub 试验一下,果然连接不上。
λ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out
然后必应搜索了一下,大家的解决方案都是更改端口号为 443,就是在存放公钥私钥的文件夹中编辑如下的 config 文件。确实奏效,不过我记得 443 是 HTTPS 连接使用的端口号,这样是不是就把连接方式从 SSH 变为 HTTPS 了呢?
Host github.com
User YourEmail@163.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443