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

栏目: 服务器 · 发布时间: 6年前

内容简介:原因:huweihuang/hexo-theme-huweihuang.git 拒绝接受 wanghaijuan。 说明当前有两个github账号,可以更新博客, 新的github账号没有配置好。解决办法:在Github生成新的SSH密钥1、打开Git Bash。

问题: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账号,可以更新博客, 新的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]

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

此时,应该在默认路径下,生成了两个文件,一个是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:

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

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

ssh-ADD~ /.ssh/hexo_rsa

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

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

验证SSH链接是否成功:

输入命令:

ssh -T git@github.com

你将会看到

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

输入Yes既可以

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


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Automate This

Automate This

Christopher Steiner / Portfolio / 2013-8-9 / USD 25.95

"The rousing story of the last gasp of human agency and how today's best and brightest minds are endeavoring to put an end to it." It used to be that to diagnose an illness, interpret legal docume......一起来看看 《Automate This》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码