針對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

相關文章
相關標籤/搜索