生成多个SSH
ssh-keygen -t rsa -C 'xxxxx@company.com' -f ~/.ssh/gitee_company_id_rsa
ssh-keygen -t rsa -C 'xxxxx@qq.com' -f ~/.ssh/github_qq_id_rsa
ssh-keygen -t rsa -C 'xxxxx@qq.com' -f ~/.ssh/gitlab_id_rsa
在 ~/.ssh 目录下新建一个config文件,添加如下内容
# gitee 主账号
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_company_id_rsa
User xxxxx@company.com
# gitee xylim
Host gitee.xylim.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_qq_id_rsa
User xxxxx@qq.com
# gitlab私服
Host git.hzlim.cn
HostName git.hzlim.cn
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_id_rsa
User root
Port 2222
命令测试
ssh -T git@gitee.com
ssh -T git@gitee.xylim.com
ssh -T git@git.hzlim.cn
克隆gitee.xylim.com账号的仓库代码
设置提交代码的信息
git config remote.origin.url git@gitee.xylim.com:xylim/homework.git