Hexo执行hexo d报错 Connection closed by 127.0.0.1 port 22

出现了如下报错

1
2
3
4
5
6
7
8
9
10
11
Connection closed by 127.0.0.1 port 22
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:\myblog\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:518:28)
at cp.emit (E:\myblog\node_modules\cross-spawn\lib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:293:12)

解决方法

我觉得是ssh出现了问题或者其他原因导致连接不到远程仓库

1.验证链接

1
ssh -T git@github.com
  • 若返回 Hi [用户名]! You've successfully authenticated,表示配置成功

说明不是ssh的问题,解决方法可以去看看别的帖子

这里如果出现问题就继续往下看

2.查看自己的密钥

1
cat ~/.ssh/id_rsa.pub  

会出现你当时自己配置好的密钥

image-20250329211520872

3.验证代理加载

1
2
eval "$(ssh-agent -s)"  # 启动代理
ssh-add ~/.ssh/id_rsa # 加载私钥[6,8](@ref)

出现如下内容

1
2
3
4
5
$ eval "$(ssh-agent -s)"
Agent pid 457

$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/用户名/.ssh/id_rsa (你的邮箱)

4.再次验证ssh

1
ssh -T git@github.com
  • 若返回 Hi [用户名]! You've successfully authenticated,表示配置成功

就可以继续hexo d部署了,一般就可以成功了