Github 生成新的SSH密钥并添加至SSH-Agent

问题:hexo d 时出现错误 Error: ERROR: Permission tohtml

remote: Permission to huweihuang/hexo-theme-huweihuang.git denied to wanghaijuan.
fatal: unable to access 'https://github.com/huweihuang/hexo-theme-huweihuang/': The requested URL returned error: 403
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html

Error: remote: Permission to huweihuang/hexo-theme-huweihuang.git denied to wanghaijuan.
fatal: unable to access 'https://github.com/huweihuang/hexo-theme-huweihuang/': The requested URL returned error: 403

    at ChildProcess.<anonymous> (D:\project\blog\hexo-huweihuang\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:37:17)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at ChildProcess.cp.emit (D:\project\blog\hexo-huweihuang\node_modules\cross-spawn-async\lib\enoent.js:37:29)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

缘由:huweihuang/hexo-theme-huweihuang.git 拒绝接受 wanghaijuan。说明当前有两个Github帐号,能够更新博客。node

在该主题下修改_config.yml中的deploy修改为本身项目地址:git

clipboard.png

若是未成功,还有多是新的Github帐号没有配置好。github

解决办法:在Github生成新的SSH密钥安全

配置步骤:hexo

1、生成新的SSH密钥

一、打开Git Bash。ssh

二、 进入.ssh 根目录下。async

cd ~/.ssh

三、输入GitHub电子邮件地址,其中your_email@example.com是您关联的GitHub邮箱。spa

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

四、输入保存的密钥文件并接受默认文件地址,按Enter键code

// 用提供的电子邮件做为标签建立一个新的ssh密钥。(无需操做)
Generating public/private rsa key pair. 
// 输入名称并按Enter键,其中hexo_rsa可自行设置
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):hexo_rsa

五、输入安全密码,没有则为空,按Enter键进行下一步

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

clipboard.png

此时,应该在默认路径下,生成了两个文件,一个是hexo_rsa,另外一个是hexo_rsa.pub;

2、将SSH密钥添加到SSH-Agent

在将新的SSH密钥添加到SSH-Agent管理密钥以前,您应该检查现有的SSH密钥。

ls -al ~/ .ssh

看下返回的结果中是否已经存在了.pub结尾的文件,若是没有须要生成一个新的,若是存在了,直接看将SSH密钥配置到Github帐户;

六、启动ssh-agent,执行命令:

eval $(ssh-agent -s)

返回agent的Pid:

clipboard.png

七、将SSH密钥添加到SSH-Agent,其中hexo_rsa是生成SSH设置的名称

ssh-ADD~ /.ssh/hexo_rsa

八、打开hexo_rsa.pub文件,复制其内容,而后打开Github帐户,按图片步骤设置,最后将复制内容放置Key内容中,设置title,点击添加便可。

clipboard.png

验证SSH连接是否成功:
输入命令:

ssh -T git@github.com

你将会看到

clipboard.png

输入Yes就能够啦~

clipboard.png

相关连接: https://help.github.com/artic...

更多文章分享https://www.artroy.com.cn/

相关文章
相关标签/搜索