1.配置好git的名字和邮箱
2.生成秘钥
ssh-keygen -t rsa -C "your email"
3.设置秘钥名字 放在~/.ssh文件夹
Enter file in which to save the key (/Users/.ssh/id_rsa): id_rsa
4.设置私钥密码
Enter passphrase (empty for no passphrase): 123456
Your identification has been saved in id_rsa. // 私钥
Your public key has been saved in id_rsa.pub. //公钥
The key fingerprint is:
SHA256:IL6L2NjBQDAAuYfD6NzTbR8VIc/fJl1coDUhzL3LYP8
The key's randomart image is:
+---[RSA 2048]----+
|B. . +o.=o.|
|o. +.o+.o.|
|o+ . . oo .o|
|*... . . .+ + .|
|+o. o . S .. * = |
| = o o o . * |
| o o . . . . |
| = o . . E|
|o + . |
+----[SHA256]-----+ // 创建成功
5.添加私钥到本地电脑上
ssh-add id_rsa
6.输入密码
Enter passphrase for id_rsa:123456
Identity added: id_rsa //添加成功
TODO
在码云或者阿里云中添加ssh后,拉取代码不成功的原因
1.mac没有开启远程登录功能,方法:设置——共享——勾选远程登录
2.打开终端 命令行输入
ssh -T git@codeup.aliyun.com
or
ssh -T git@gitee.com 回车
与网站进行验证,记录ssh
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes