天天看点

Git SSH Key 生成并添加到github/gitee步骤#yyds干货盘点#

大家好,这里是坚果前端小课堂,欢迎大家关注我的公众号,“坚果前端”​

Git SSH Key 生成并添加到github/gitee步骤#yyds干货盘点#

Git SSH Key 生成并添加到github/gitee步骤

在本地生成密钥

Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置。

一,github的SSH配置如下:

设置Git的user name和email:

git config --global user.name "坚果前端"      
git config --global user.email "[email protected]"      

二、生成SSH密钥过程:

1.查看是否已经有了ssh密钥:cd ~/.ssh

如果没有密钥则不会有此文件夹,有则备份删除

2.生存密钥:

$ ssh-keygen -t rsa -C “​​[email protected]​​”

按3个回车,密码为空。

最后得到了两个文件:id_rsa和id_rsa.pub

Git SSH Key 生成并添加到github/gitee步骤#yyds干货盘点#
Git SSH Key 生成并添加到github/gitee步骤#yyds干货盘点#

3.添加密钥到ssh:ssh-add 文件名

需要之前输入密码。

4.在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。

打开​​https://github.com/​​ ,登陆,然后添加ssh。

Git SSH Key 生成并添加到github/gitee步骤#yyds干货盘点#

5.在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。

6.测试:

ssh [email protected]      
ssh [email protected]