MacBook 生成Git SHH Key

1:进入ssh文件下

cd ~/ .ssh

2:生成ssh key

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

3:提示输入目录,目录可以不填,有默认路径,直接回车

// '()'里面是默认路径
Enter file in which to save the key (/Users/user/.ssh/id_rsa):

4:提示输入密码, 密码可以不填, 默认没有密码,直接回车

5:提示再次输入密码

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

6:当出现以下图案, 则表示生成 成功

Your identification has been saved in /Users/user/.ssh/id_rsa.
Your public key has been saved in /Users/user/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:IQP0sSMslL9VG+HXO9oqlnFNTkeI1/m9fBiBoKIcdxk nanananamln@163.com
The key's randomart image is:
+---[RSA 2048]----+
|  .oo . E..o + . |
| ... o +o+..+ =  |
|  ..+ O.*o.... o.|
|   o.=.*.o  o.o o|
|    oo  S  =o..o.|
|    .   . .oo..o.|
|         +. .   .|
|        +  .     |
|       . ..      |
+----[SHA256]-----+

6:打开.pub文件复制生成的ssh key粘贴到Git上即可

// 路径是上面的默认路径
sudo vi ~/.ssh/id_rsa.pub 

也可以直接用命令把key复制到剪贴板

pbcopy < ~/.ssh/id_rsa.pub

7:配置一下Git


git config --global user.email "你的邮箱"
   git config --global user.name "你的名字"

The End


已发布

分类

标签:

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注