Mac sourcetree 配置 ssh 密钥
2020-06-30 本文已影响0人
Yobhel
1 在普通用户 进入 .ssh 文件.(.ssh 文件生成百度很多)
cd .ssh/ 或 cd ~/.ssh
LELEdeMacBook-Pro:~ lele$ cd .ssh/
LELEdeMacBook-Pro:.ssh lele$ ls
known_hosts
LELEdeMacBook-Pro:.ssh lele$ ssh-keygen -t rsa -C "your email" // 你的邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/lele/.ssh/id_rsa): id_rsa1// 给生成生成私钥命名
Enter passphrase (empty for no passphrase): // 设置输入密码
Enter same passphrase again:
Your identification has been saved in id_rsa1. // 私钥
Your public key has been saved in id_rsa1.pub. // 公钥
The key fingerprint is:
SHA256:IL6L2NjBQDAAuYfD6NzTbR8VIc/fJl1coDUhzL3LYP8 leyu@chargedot.com
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]-----+
LELEdeMacBook-Pro:.ssh lele$ ls// 查看生成文件
id_rsa id_rsa1id_rsa1.pubknown_hosts
LELEdeMacBook-Pro:.ssh lele$ cat id_rsa1.pub // 打开公钥 复制公钥粘贴到 gitlab上设置 sshKey 的地方
- gitlab设置sshkay的方法:我用的阿里的,以阿里的为例,找到左侧sshkey一栏,然后点击右侧Add sshkay,把公钥粘贴进去就好,名字自动设置为你的邮箱号,当然,自己随便起一个也行,设置完就可以正常克隆项目了。
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIRPiN+aEeJ4ZAYshiKdDSv9tHovvmKCIai8uUc8RqxYo5BPJwN5NLH5FVKgIO12uj4PZl4q/QpXh9oaPVKJLZWTGh7aZc2lBmqS8CDLnFAniFnhYb5CABg+gQyFv71857UeV4QaO6sPas6jYFyeMgguEylzFUVz2dxsjonoGnPxA14YxG0k1bvkuQT1MEuwcyN17vOZYPOyh5xBfTJMYrqp3V875ju508SUgE+oFYXoJF/bMoUXPH+9D7YSTTqbocv55Su7z95/LMhp5RNX4MwMxJF9LdcLwTWvXuPucB6RbsRLqf9hy53/boLyphgc0UKpHNgPZTnCYRKJ8+hwrL leyu@chargedot.com
再执行以下操作
LELEdeMacBook-Pro:.ssh lele$ ls
id_rsa id_rsa1id_rsa1.pubknown_hosts
LELEdeMacBook-Pro:.ssh lele$ ssh-add id_rsa1// 添加私钥
Enter passphrase for id_rsa1:// 输入密码 此密码为生成密钥的时候设置的密码 123456 方便好记 哈哈
Identity added: id_rsa1 (id_rsa1)
至此 sshKey 配置完成,打开 source tree 克隆代码就 OK 了
- 注: 一段时间之后, 如果出现提交或拉取代码失败,则需要重新在终端添加一下私钥即可。