1. 打开终端,确认是否安装git (git都没有的话,别玩了,把电脑关机吧)
lepu@zsyLepu ~ % git --version
git version 2.39.2 (Apple Git-143)
2. 已经安装,则直接生成密钥
通过指令 ssh-keygen -t rsa -C 'xxxx@viatom.cc'
xxxx@viatom.cc是自己的git邮箱
lepu@zsyLepu ~ % ssh-keygen -t rsa -C 'xxxx@viatom.cc'
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/lepu/.ssh/id_rsa):
/Users/lepu/.ssh/id_rsa already exists.
Overwrite (y/n)? y //已经生成过,直接覆盖 y
Enter passphrase (empty for no passphrase): //直接回车
Enter same passphrase again: //直接回车
Your identification has been saved in /Users/lepu/.ssh/id_rsa
Your public key has been saved in /Users/lepu/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:/GIAwcEjsrWGlIH3d+MF8eze8OfxbOf2/1guOxZ6d74 xxxx@viatom.cc
The key's randomart image is:
+---[RSA 3072]----+
|..ooo. .. |
|oo+ +. .o |
|.* +.. .o |
|o o ....o.. |
| . ..oSoo |
| ..o + . |
| o o o.o..|
| . . .o=B*|
| o+E^|
+----[SHA256]-----+
3. 到上面提到的文件夹中查找
注:mac可以通过文本编辑工具打开.pub文件 ,复制里面的内容