Git生成本机SSH Key并添加到GitHub中

时间:2023-03-09 18:49:50
Git生成本机SSH Key并添加到GitHub中

1.检查电脑里是否有SSH Key

打开git Bash客户端

cd ~/.ssh
ls

如果有就会输出下面内容

config  id_rsa  id_rsa.pub  known_hosts

2.创建

邮箱为注册github的邮箱

ssh-keygen -t rsa -C "你的邮箱"

可以直接按enter键

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/peng/.ssh/id_rsa):

也可以指定目录

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/peng/.ssh/id_rsa): C:\Users\peng\ssh\id_rsa

提示输入密码,直接按enter键

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

成功后会提示

Your identification has been saved in C:\Users\peng\ssh\id_rsa.
Your public key has been saved in C:\Users\peng\ssh\id_rsa.pub.
The key fingerprint is:
SHA256:I3MqfNzPqqsjwDDhunBFZpPJ/qSSDlbY+TQGvN7HRUk @qq.com
The key's randomart image is:
+---[RSA ]----+
| .. o .E. |
|. oO o |
|..o=+. . |
|oo =o+. . |
|+.oo=+= S |
|=o+o.+.O . |
|o* .o = . |
|. o .o o |
| ..ooo..o |
+----[SHA256]-----+

3.在github添加ssh key

将id_rsa.pub文件内容复制到github的ssh key里

Git生成本机SSH Key并添加到GitHub中