hexo d 报错ssh: connect to host github.com port 22: Connection timed out

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> (E:\Blog\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (events.js:400:28)
at ChildProcess.cp.emit (E:\Blog\node_modules\cross-spawn\lib\enoent.js:34:29)
at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
PS E:\Blog>

在命令行直接输入 ssh -T git@github.com 连接GitHub,返回:

C:\Users\craft>ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out

如果 hexo d 以前都是好的,今天突然抽风了,那应该不是ssh密钥的问题,而是端口被防火墙禁止访问了,我们尝试修改 ~/.ssh/config 使用443端口来访问:

  1. 命令行 cd %USERPROFILE%\.ssh
  2. notepad config 编辑 config 文件
  3. 在 notepad 中,输入以下内容:
Host github.com
Hostname ssh.github.com
Port 443

然后,在命令行输入 ssh -T git@github.com 返回:

C:\Users\craft>ssh -T git@github.com
Hi Diraw! You've successfully authenticated, but GitHub does not provide shell access.

然后再 hexo d 应该就没问题了。