1 在普通用戶 進(jìn)入 .ssh 文件.(.ssh 文件生成百度很多) ? ? ??cd .ssh/ ? ?或 cd ~/.ssh
LELEdeMacBook-Pro:~ lele$ cd .ssh/
LELEdeMacBook-Pro:.ssh lele$ ls
known_hosts
LELEdeMacBook-Pro:.ssh lele$?
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):?// 設(shè)置輸入密碼
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$?
LELEdeMacBook-Pro:.ssh lele$?
LELEdeMacBook-Pro:.ssh lele$?
LELEdeMacBook-Pro:.ssh lele$ ls// 查看生成文件
id_rsa id_rsa1id_rsa1.pubknown_hosts
LELEdeMacBook-Pro:.ssh lele$ cat id_rsa1.pub?// 打開公鑰 ?復(fù)制公鑰粘貼到 gitlab上設(shè)置 sshKey 的地方
>gitlab設(shè)置sshkay的方法:我用的阿里的,以阿里的為例,找到左側(cè)sshkey一欄,然后點(diǎn)擊右側(cè)Add sshkay尺锚,把公鑰粘貼進(jìn)去就好,名字自動(dòng)設(shè)置為你的郵箱號(hào),當(dāng)然狸棍,自己隨便起一個(gè)也行,設(shè)置完就可以正澄肚模克隆項(xiàng)目了草戈。
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:// 輸入密碼 ?此密碼為生成密鑰的時(shí)候設(shè)置的密碼 123456 方便好記 哈哈
Identity added: id_rsa1 (id_rsa1)
LELEdeMacBook-Pro:.ssh lele$?
至此 sshKey 配置完成,打開 source tree 克隆代碼就 OK 了
/**注:
?一段時(shí)間之后,?如果出現(xiàn)提交或拉取代碼失敗,則需要重新在終端添加一下私鑰即可侍瑟。
**/
參考文章:
https://blog.csdn.net/lele9096_bk/article/details/54950391