hexojs / hexo-deployer-git

Git deployer plugin for Hexo.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to specify a privateKey's Path

iljh opened this issue · comments

commented

When I tried to using ssh key to deploy hexo blog on Github Pages, I find a problem that my privateKey is not the default name "id_rsa". So when I used hexo d to deploy, it occurred an error. The error message is blow:

It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/root/.ssh/id_rsa": bad permissions
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at ChildProcess.<anonymous> (/root/new_blog/node_modules/hexo-util/lib/spawn.js:37:17)
    at ChildProcess.emit (events.js:160:13)
    at maybeClose (internal/child_process.js:943:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)

My SSH privateKey is /root/.ssh/hexo.id_rsa and the hexo blog setting file's content about deployment is blow:

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: ssh://github.com/iljh/iljh.github.io.git
  branch: master
  message: i love github!
  privateKey: /root/.ssh/hexo.id_rsa

I have tested my privateKey and it works.

root@VM-71-41-debian:~/new_blog# ssh -i /root/.ssh/hexo.id_rsa -T git@github.com
Hi iljh/iljh.github.io! You've successfully authenticated, but GitHub does not provide shell access.

I do not want to rename my privateKey's name. I google it for a long time but got nothing. Could you give me some suggestions? Thanks a lot!

commented

Aha…I just solved the problem. Create a config file in ~/.ssh/ and write following in it:

Host github.com
  User git
  StrictHostKeyChecking no
  IdentityFile ~/.ssh/hexo.id_rsa
  IdentitiesOnly yes