解决一个Hexo deploy报错问题

##解决一个Hexo deploy报错问题

部署hexo博客到github时报错如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
~/jiangcheng-pages $ hexo d -g
INFO Validating config
INFO Start processing
WARN ===============================================================
WARN ========================= ATTENTION! ==========================
WARN ===============================================================
WARN NexT repository is moving here: https://github.com/theme-next
WARN ===============================================================
WARN It's rebase to v6.0.0 and future maintenance will resume there
WARN ===============================================================
INFO Files loaded in 803 ms
INFO 0 files generated in 55 ms
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
INFO Copying files from extend dirs...
On branch master
nothing to commit, working tree clean
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> (/data/data/com.termux/files/home/jiangcheng-pages/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:511:28)
at ChildProcess._handle.onexit (node:internal/child_process:293:12)

按网上很多网友推荐的不断的重试hexo d命令并没有解决问题,猜想可能是ssh公钥不匹配的问题,然后比较了本地id_rsa.pub与github上个人配置的sshkey,发现名字一样,但是隐约感觉有什么不对,我的服务器是termux,之前只有使用ssh登陆termux上的记录,所以这个公钥是其他服务器上粘贴过来的,于是删除这个公钥并重新创建了一个秘钥对,解决了问题,命令如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
~/jiangcheng-pages $
~/jiangcheng-pages $
~/jiangcheng-pages $ ls ~/.ssh/
authorized_keys id_rsa.pub known_hosts
~/jiangcheng-pages $ rm -f ~/.ssh/id_rsa.pub
~/jiangcheng-pages $
~/jiangcheng-pages $
~/jiangcheng-pages $
~/jiangcheng-pages $ ssh-keygen -t rsa -C "jiangcheng1806@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/data/data/com.termux/files/home/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /data/data/com.termux/files/home/.ssh/id_rsa
Your public key has been saved in /data/data/com.termux/files/home/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:6plhjlQPdfEr/uxuMWKwFBjcQ288FbpOYAOI3j+gua0 jiangcheng1806@qq.com
The key's randomart image is:
+---[RSA 3072]----+
| . oo=. . o. |
| . . o.+o = |
| . . =oB . |
| . o oo= o . |
| o oo.So+ . |
| o .o+.+o.o |
| o. +...o. o |
| ...= + o. |
| E.. = += |
+----[SHA256]-----+
~/jiangcheng-pages $
~/jiangcheng-pages $
~/jiangcheng-pages $

创建好本地的id_rsa.pub之后配置到github个人ssh key配置,之后执行命令,问题解决

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
~/jiangcheng-pages $ hexo d -g
INFO Validating config
INFO Start processing
WARN ===============================================================
WARN ========================= ATTENTION! ==========================
WARN ===============================================================
WARN NexT repository is moving here: https://github.com/theme-next
WARN ===============================================================
WARN It's rebase to v6.0.0 and future maintenance will resume there
WARN ===============================================================
INFO Files loaded in 815 ms
INFO 0 files generated in 56 ms
INFO Deploying: git
INFO Clearing .deploy_git folder...
INFO Copying files from public folder...
INFO Copying files from extend dirs...
On branch master
nothing to commit, working tree clean
Enumerating objects: 192, done.
Counting objects: 100% (192/192), done.
Delta compression using up to 8 threads
Compressing objects: 100% (174/174), done.
Writing objects: 100% (192/192), 1.88 MiB | 1.14 MiB/s, done.
Total 192 (delta 13), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (13/13), done.
To github.com:jiangcheng1806/sky-jiangcheng.github.io.git
* [new branch] HEAD -> master
branch 'master' set up to track 'git@github.com:jiangcheng1806/sky-jiangcheng.github.io.git/master'.
INFO Deploy done: git
~/jiangcheng-pages $