解决hexo本地上传报错之ssh连接

近期本地博客上传遇到了以下报错:

1
2
3
4
5
6
7
8
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\Hexo\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:513:28)
at cp.emit (E:\Blog\Hexo\node_modules\cross-spawn\lib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:291:12)

关键问题出在错误的第一行,git服务器没有成功发现存储在本地的ssh密钥或者说是本地的ssh密钥出现问题

测试发现确实连接失败

1
ssh -T git@github.com

image-20240123124721799

查看本地的.ssh目录下的配制文件

image-20240123124527185

可以发现这里我因为vscode连ubuntu远程写代码导致之前的ssh配置被修改

直接下方添加域名:

1
2
3
4
Host github.com
HostName ssh.github.com
User d3f4u1t
Port 22

image-20240125120809175

再次连接,成功,本地文件也可以成功push

image-20240123124758608