Mac 配置sourcetree ssh密钥

打开终端, 执行以下操作:

YANGdeMacBook-Pro:~ chengruiyang$ cd ~/.ssh

YANGdeMacBook-Pro:.ssh chengruiyang$ ssh-keygen -t rsa -C "yangyang@***.com"      // <注> 邮箱地址

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/chengruiyang/.ssh/id_rsa): id_rsa_DCB

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in id_rsa_DCB.

Your public key has been saved in id_rsa_DCB.pub.

The key fingerprint is:

SHA256:Mc5yvH20fWu8KnsVjK101b73hZ3qVXLUJImh0frzhaA yangyang@***.com   // <注> 邮箱地址

The key's randomart image is:

+---[RSA 2048]----+

|          ...o..o|

|           oo .o+|

|        o ..  +.+|

|       + o. .o *.|

|      . S  oo.++*|

|       o oE.o+o**|

|        . . oo=o=|

|           o oo+o|

|           .=ooo.|

+----[SHA256]-----+

YANGdeMacBook-Pro:.ssh chengruiyang$

 

添加公司的到信任列表

192:~ chengruiyang$ ssh-add ~/.ssh/id_rsa_DCB

Enter passphrase for /Users/chengruiyang/.ssh/id_rsa_DCB:

Identity added: /Users/chengruiyang/.ssh/id_rsa_DCB (yangyang@***.com)  // <注> 邮箱地址

192:~ chengruiyang$

 

新建config文件

192:~ chengruiyang$ cd ~/.ssh

192:.ssh chengruiyang$ touch config

 

cofig添加以下内容, 以便做多账户区分
#DCB项目
Host yangyang.git.***.com
Hostname git.***.com  // 公司代码git地址
IdentityFile ~/.ssh/id_rsa_DCB

User yangyang

 

查看ssh

cat /Users/chengruiyang/.ssh/id_rsa_DCB.pub

之后copy到远程项目的SSH Keys下

<注>: 以上全部操作亦适用于Mac下设置多个Git账户

你可能感兴趣的:(Mac 配置sourcetree ssh密钥)