生成SSH-Key
ssh-keygen -t rsa -C 'xxx@xxx.com' -f ~/.ssh/gitee1_id_rsa
ssh-keygen -t rsa -C 'xxx@xxx.com' -f ~/.ssh/gitee2_id_rsa
ssh-keygen -t rsa -C 'xxx@xxx.com' -f ~/.ssh/github_id_rsa
添加配置文件
在 ~/.ssh 目录下新建一个config文件
touch config
添加如下内容
# gitee1
Host gitee1.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee1_id_rsa
# gitee2
Host gitee2.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee2_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
在各自网站上配置SSH-Key
Clone
仓库ssh访问地址格式 git@[host]:用户名/项目名.git
[host]就是config文件中的Host
将原始地址的git@[host]中的host部分替换为config文件中Host就可以了