Fixing Hexo Blog Deployment 'Permission Denied' Error

1 Problem

Previously, I modified my GitHub username, which led to an issue when attempting to deploy my Hexo blog from my PC.

While I can successfully push updates to other repositories, I encountered an error specifically with the Hexo blog deployment. I suspect there might be a bug within the Hexo settings. The error I encountered was when executing the command hexo d.

1
2
3
4
5
6
7
8
9
10
git@github.com: Permission denied (publickey).
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> (/Users/xxx/Git/Hexo/node_modules/hexo-deployer-git/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:390:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)

After conducting a thorough search, I attempted to change the token, but unfortunately, it didn't resolve the issue for me.

2 Solution

The solution, while straightforward, is not readily available on the internet.

You simply need to execute the following command to test your connection

1
ssh -vT git@github.com