shou ye

Git 配置SSH公钥、私钥

开篇日常立个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)

 

TortoiseGit 提交报错

提示:

No supported authentication methods available(server sent: publickey)
设置里面 -> Network -> SSH -> SSH client
改成 Git 的 SSH lient

参考

 

posted @ 2021-01-17 08:36  芦荟柚子茶  阅读(1038)  评论(0编辑  收藏  举报
ye jiao