ssh-keygen -t rsa -C"your email address"
# one
Host github
HostName github.com
User one
IdentityFile ~/.ssh/id_rsa_one
# second
Host gitlab
HostName gitlab.com
User second
IdentityFile ~/.ssh/id_rsa_second
然后执行
ssh-agent bash
ssh-add id_rsa_one
ssh-add id_rsa_second
然后测试一下,测试命令
ssh -T git@github
ssh -T git@gitlab
如果遇到提示Permission denied
先去你的仓库把SSH key加上,按图顺序添加