Hexo deploy遇到的坑

这几天在更新博客的时候发现使用命令“hexo d”进行提交时失败,错误提示如下:

INFO  Deploying: git
INFO Clearing .deploy_git folder…
INFO Copying files from public folder…
On branch master
nothing to commit, working directory clean
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: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

在网上找了很多方法,有git降级的,有重新生成ssh key然后将public key 添加到github上的,几乎所有的都折腾了一边,然并卵……,功夫不负有心人,最后还是搞定了,特此记录一下,以备不时之需。
步骤:
1:cd[空格]切换到底层目录
  cd .ssh切换到ssh文件夹,ls查看文件夹内是否包含id_rsa 和 id_rsa.pub文件:
  1-1:如果是官方的github的,那就直接cat id_rsa.pub命令会显示出公钥的内容,直接copy然后在github的setting->SSH and GPG keys - >New SSH key,将生成的公钥添加进入即可.
  1-2:如果这两个文件是你自己公司的git系统的sshkey文件,那就需要你生成新的密钥文件(我遇到的就是这种情况,坑啊!)
2:ssh-keygen -t rsa -C “*@163.com”(你自己的邮箱)
回车后,会提示你输入生成文件的位置和名称,如果不输入会生成到默认的位置和名称,如果你本地有默认的文件,切记一定要输入其他的名字如 github_rsa,回车后会在ssh下面生成github_rsa和github_rsa.pub两个文件。
3:ssh-add -L命令可以查看本地密钥列表内是否包含你刚才生成文件名称,如果有,直接使用1-1的步骤将公钥添加到github即可,如果密钥列表内没有刚才生成的密钥文件,则使用ssh-add github_rsa将其添加到密钥列表,可以通过ssh-add -L查看是否添加成功。
通过以上步骤,我遇到的问题就这样解决了……

热评文章