针对github权限致使hexo部署失败的解决方案

hexo deplay出错,没有反应

今天想在本身的另外一个博客地址(连接地址)上更新一下博客,没想到hexo deplay没有反应,如下是解决过程:(更新于 2016-12-24 11:17:43)html

一、由于没有报错信息,因此直接在网上搜解决方案,集广大网友们的智慧,而后使用了npm install hexo-deployer-git --save,然后hexo deploy,可是没有解决问题,并且爆出警告:node

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.15

二、更新npm npm install npm -g ,更新成功git

三、继续npm install hexo-deployer-git --save,hexo deploy 仍是不行:github

INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
fatal: Not a git repository (or any of the parent directories): .git
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: fatal: Not a git repository (or any of the parent directories): .git

    at ChildProcess.<anonymous> (E:\blog\HexoBlog\node_modules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:87:13)
    ……
    (E:\blog\HexoBlog\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:827:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:477:12)

四、后来灵机一动,把.deploy_git文件夹手动删除了,从新hexo deploy了一次,成功!shell


问题描述:

如题,hexo最后一次部署是在8月份,而后就是秋招,一直没有在hexo博客上上传新博文,等回过头打算整理几篇博客上传,发现一直部署失败,经过搜索网上前辈们的经验,我决定从新使用hexo+github pages搭建博客(顺便更新版本了),然而······并无什么卵用······npm

错误依旧以下(这已是重复设置SSH key后的错误版本啦,与一开始的错误描述略有不一样,不过都是github权限问题):windows

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: http://hexo.io/docs/troubleshooting.html
Error: Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
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> (E:\blog\HexoBlog\node_modules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at ChildProcess.cp.emit (E:\blog\HexoBlog\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:827:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
FATAL Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

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

Error: Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
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> (E:\blog\HexoBlog\node_modules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at ChildProcess.cp.emit (E:\blog\HexoBlog\node_modules\cross-spawn\lib\enoent.js:40:29)
    at maybeClose (internal/child_process.js:827:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

以前的错误,有网友们有建议将deploy处设置不要使用https,而是改成SSH,以下:bash

repository: https://github.com/username/username.github.io.git

修改成hexo

repo:git@github.com:username/username.github.io.git

修改了不少遍,以各类姿式······然而仍是没有什么卵用dom

固然错误不是重点,重点是怎样使咱们的博客能够从新部署到github上~

当部署失败的时候,请按照如下步骤进行:

(固然,在此以前,你能够选择 hexo init)教程有不少,一搜就能够,懒癌症能够点击传送门,这是一个比较全的搭建配置教程。

(1)检查是否有SSH key

登录github,点击头像位置处 Settings ——> SSH and GPG keys ,查看是否有SSH keys。若是有,直接跳到第(3)步;若是没有,则继续。

(2)新建 SSH key,在git shell(或者git bash等命令窗口),注意大小写:

$ ssh-keygen -t rsa -C "邮箱名"

而后会出现:

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/dell/.ssh/id_rsa):

直接回车就能够。
而后会出现:

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

要求你输入密码,这个密码会在你提交项目时使用,若是为空的话提交项目时则不用输入。这个设置是防止别人往你的项目里提交内容。

注意:输入密码的时候没有*字样的,直接输入就好。
而后会出现:

Your identification has been saved in /c/Users/dell/.ssh/id_rsa.
Your public key has been saved in /c/Users/dell/.ssh/id_rsa.pub.
The key fingerprint is:
65:69:······02:4b emailname@email.com
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|       .   o .   |
|    . o o = o    |
|   . o * = o     |
|  E  o + o .     |
| . o.   . .      |
|     ..          |
+-----------------+

至此,密钥已经成功生成。

(3)接下来在github上添加SSH key:

① 打开本地文件:id_rsa.pub(文件路径能够在上一步SSH生成成功后看到路径,好比个人是c/Users/dell/.ssh/id_rsa.pub),能够将这个文件在编辑器中打开,而后全选复制。

② 登录github,点击头像位置处 Settings ——> SSH and GPG keys ——> New SSH key,点击新建SSH key。

③ 将 ① 中复制的内容粘贴在key文本框里,title能够不用填(或者本身起一个名字也能够)。

(4)测试设置是否成功:

$ ssh -T git@github.com

有可能会出现:

The authenticity of host 'github.com (192.30.252.1)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?

或者是

The authenticity of host 'github.com (192.30.252.1)' can't be established.
RSA key fingerprint is nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?

这种状况下,直接 yes 回车

而后会出现(也可能在 ++$ ssh -T git@github.com++ 以后,直接出现的就是这个,我就是这样~):

Hi username! You've successfully authenticated, but GitHub does not 
provide shell access.

(5)设置用户信息:

$ git config --global user.name "用户名"
$ git config --global user.email  "你但愿的邮箱名"

(6)而后就能够部署你的博客到github啦~

$ hexo g
$ hexo d

(7)更多常见hexo命令,传送门

补充1:过程当中也遇到一些其余问题,好比Error: Bad file number,可是总的来讲,按照上面的步骤就能够解决由于github权限问题hexo部署失败的问题(前提是你的配置文件的内容没有问题)。

补充2:windows系统不要使用它本身的命令窗口!!!使用git shell或者 git bash 等之类的一些工具。

引用借鉴:

Generating an SSH key

common SSH Problems

hexo经常使用命令笔记

hexo你的博客

本文连接:http://www.cnblogs.com/xsilence/p/6001938.html

相关文章
相关标签/搜索