# 配置多git平台的ssh的方法
*****
场景:个人的阿里云云效里面存的有自己的git仓库,现在需要配置一个公司的云效git的ssh密钥,实现git克隆、拉取、推送(等正常的开发流程)
1. 生成ssh密钥对(-C 里面,写的是注释,而不是账号,习惯写成了账号;cat 查看pub公钥;-f 后面跟的具体文件的保存路径)
生成的第一个ssh密钥对命令:
```
ssh-keygen -t rsa -C "wangyaqiang@1944796833270755.onaliyun.com" -f ~/.ssh/id_rsa_judian
```
查看一个生成的公钥命令:
```
cat ~/.ssh/id_rsa_judian.pub
```
生成的第二个ssh密钥对命令:
```
ssh-keygen -t rsa -C "1013762171@qq.com" -f ~/.ssh/id_rsa_self
```
查看第二个生成的公钥命令:
```
cat ~/.ssh/id_rsa_self.pub
```

2. 配置多ssh的方法(位置:~/.ssh,或者:C:\Users\Administrator\\.ssh)在此目录,創建config文件,内容如下:
```
# 剧点云效
Host codeup_judian_yunxiao
HostName codeup.aliyun.com
IdentityFile C:\Users\Administrator\.ssh\id_rsa_judian
PreferredAuthentications publickey
IdentityAgent none
IdentitiesOnly yes
# self云效
Host codeup_self_yunxiao
HostName codeup.aliyun.com
User 阳泽一生
IdentityFile C:\Users\Administrator\.ssh\id_rsa_self
PreferredAuthentications publickey
IdentityAgent none
IdentitiesOnly yes
```

3. 找到git管理平台的ssh密钥中,將pub公钥复制上去,在任意位置,执行(上面的是公司阿里云云效的ssh,下面的是个人阿里云云效的ssh),以下两个命令:
Administrator@Tomorrow MINGW64 <span style="color:red">~/.ssh</span>
$(当前位置)<span style="color:red">ssh -T -F ~/.ssh/config git@codeup_judian_yunxiao</span>
<span style="color:blue">Welcome to Codeup, 王亚强!</span>
Administrator@Tomorrow MINGW64(当前位置) <span style="color:red">~/.ssh</span>
$(当前位置) <span style="color:red">ssh -T -F ~/.ssh/config git@codeup_self_yunxiao</span>
<span style="color:blue">Welcome to Codeup, 阳泽一生!</span>

4:上述出现结果,代表多账户(多平台)的ssh配置ok

5:可以执行git clone ssh地址(使用config配置的别名)了;原ssh地址:
```
git@codeup.aliyun.com:6409d268e9f200d37adc2ffd/WEB/vuePress.git
```
别名的ssh地址:
```
git@codeup_self_yunxiao:6409d268e9f200d37adc2ffd/WEB/vuePress.git
```
克隆仓库(使用git仓库别名地址进行克隆):
```
git clone git@codeup_self_yunxiao:6409d268e9f200d37adc2ffd/WEB/vuePress.git
```

