Git 配置SSH公钥、私钥
发布日期:2021-05-09 01:29:07 浏览次数:12 分类:博客文章

本文共 1107 字,大约阅读时间需要 3 分钟。

开篇日常立个flag....

 

安装Git

此处略去一万字

 

了解几个东西

为什么要配置公钥、私钥?配置了有什么用(对于Git)?怎么配置?

(以后补充)

 

Git 配置SSH公钥、私钥

1、进入Git Bash

鼠标右键<Git Bash Here>(或者文件路径里敲<Git Bash.lnk>)

2、输入生成 Rsa 秘钥对的命令

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

3、秘钥名称

Enter file in which to save the key (/c/Users/CL/.ssh/id_rsa): <输入秘钥名称/直接回车>

注:本例中,输入秘钥名称为:lisheng741

4、输入密码和确认密码

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

都可空,直接回车,等待生成秘钥对。

本地会生成两个文件:

lisheng741     私钥

lisheng741.pub   公钥

5、本地添加私钥

ssh-add <私钥路径>

6、读取公钥

方式1:cat <公钥文件>

方式2:以文本方式打开公钥文件

将公钥文本复制,用于下一步

7、在 Github / Gitee 添加公钥

Github:点自己头像 >> Settings >> SSH and GPG keys >>New SSH key 

Gitee:点自己头像 >> 设置 >> SS公钥 

参考来源

https://blog.csdn.net/july_young/article/details/82712574 (july_young 的 git添加私钥)

https://www.cnblogs.com/kaerxifa/p/11164206.html (wangju003 的 git配置密钥(私钥、ssh、公钥))

 

Git配置SSH公钥、私钥 踩坑记录

第5步本地添加私钥时,提示:

Could not open a connection to your authentication agent.

具体原因没有细究,解决方案:先执行命令:ssh-agent bash

参考来源

https://www.cnblogs.com/sheldonxu/archive/2012/09/17/2688281.html (Sheldon Xu 的 执行ssh-add时出现Could not open a connection to your authentication agent)

 

上一篇:Git 记录
下一篇:.NET5.0 MVC 搭建笔记(VS2019)

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年04月12日 02时30分48秒