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

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

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账号,可以更新博客。

在该主题下修改_config.yml中的deploy修改成自己项目地址:

clipboard.png

如果未成功,还有可能是新的Github账号没有配置好。

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

配置步骤:

一、生成新的SSH密钥

1、打开Git Bash。

2、 进入.ssh 根目录下。

cd ~/.ssh

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

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

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

// 用提供的电子邮件作为标签创建一个新的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

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

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

clipboard.png

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

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

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

ls -al ~/ .ssh

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

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

eval $(ssh-agent -s)

返回agent的Pid:

clipboard.png

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

ssh-ADD~ /.ssh/hexo_rsa

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

clipboard.png

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

ssh -T git@github.com

你将会看到

clipboard.png

输入Yes就可以啦~

clipboard.png

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值