mac下先要有rsa的密钥文件.
1.打开终端, 在中断命令行中键入$ ssh-keygen -t rsa -C "3476228**@qq.com" ,邮箱是你github中使用的绑定邮箱,非github的名字,必须使用双引号将邮箱包含.
2.键入之后出现:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/jimmyhou/.ssh/id_rsa):
这里直接按回车,不输入名字, 则使用原来的id_rsa作为文件名. 系统读取默认使用id_rsa来作为密钥.所以这里不改.
3.输入回车之后:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
全部回车,不输入密码,则以后push代码的时候也不用密码.
4.上述操作完成后,文件生成
Your identification has been saved in /Users/jimmyhou/.ssh/id_rsa.
Your public key has been saved in /Users/jimmyhou/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:A1heAQy+2yWIEWn3Ehsp0b93UanOkr9ZonRVkk0bZ= 3476228**@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| o+.+o.o. .=..|
| +o*+.. o* o.|
| ..oo*o oo + E|
| oooo. o o |
| . o...S+ .. |
| o.o+.+. |
| . ...+o . |
=***
+----[SHA256]-----+
文件存在于/Users/jimmyhou/.ssh/id_rsa下.
5.获取rsa密钥内容
进入隐藏文件夹.ssh中. JimmydeMacBook-Pro:~ jimmyhou$ cd ~/.ssh
键入ls,查看文件夹中的文件为id_rsa id_rsa.pub known_hosts.
在当前文件夹下键入命令: JimmydeMacBook-Pro:.ssh jimmyhou$ cat id_rsa.pub
终端打印内容:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9Pzs4kb4kA5HNn6NSaqtl8p9QuJrrN7tWrY+Nx4ZaYF1ACwY/j4uIjcO3eob6bRdFeGDV0pbLVmMkNjoue+QmcVIWHTv3CIq2UmfaRjTxtWWwO6LyMxtopktzuBLjrUzYX+E7xvYWCKhXVPZlMF3Uf0azsID7oTC/VKx0FBTm/SGFHN6rkiQvxm+UY69bpQ9GQn9Z4in0oHQm5u+zEHrDdI0wkGoxSnrzLD62LptnYRVLWqiSCUi5RZfPAanxaF6oxbfiZ/GaYmX+tQhuGPBGvP4iAas6QtlfWjC9dqXUNuxYltqTCMcBZu09JpuFGhJtvyeBEb27TrLOe7Mz 3476228**@qq.com
6.将密钥填写到github中.title随意. 将中断打印的内容全部填写到key对应的输入框中.点击add即可.
7.add成功之后, mac终端上输入JimmydeMacBook-Pro:.ssh jimmyhou$ ssh -T [email protected]
屏幕打印如下,则完成ssh密钥
Hi FantasyEngineer! You've successfully authenticated, but GitHub does not provide shell access.