Git SSH keys 从生成到使用

觉得内容不错请关注个人博客:https://lijianxun.top/
最新文章将在个人博客上发布。
原文地址:https://lijianxun.top/157.html

配置 git 用户名和邮箱

git config --global user.name "git 用户名"
git config --global user.email "git 邮箱"

生成公钥和私钥

ssh-keygen -t rsa -C "git 邮箱"

然后一路回车,直到生成类似的图形:

+--[ RSA 2048]----+
|                 |
|                 |
|        . E +    |
|       . o = .   |
|      . S =   o  |
|       o.O . o   |
|       o .+ .    |
|      . o+..     |
|       .+=o      |
+-----------------+

获取 id_rsa.pub

找到 .ssh 目录,查看 id_rsa.pub 文件,全部复制,接下来去 github 里配置。

配置 github

在 github 的设置里找到 SSH and GPG key,填入名称和刚复制的内容,保存即可。

这样配置以后就可以直接使用 [email protected] 开头的仓库链接,不再输入用户名和密码。

觉得内容不错请关注个人博客:https://lijianxun.top/
最新文章将在个人博客上发布。
原文地址:https://lijianxun.top/157.html

发布了72 篇原创文章 · 获赞 42 · 访问量 39万+

猜你喜欢

转载自blog.csdn.net/A_lPha/article/details/104260507