一个电脑下添加多个gitlab/github账号
首先必须明白:
一个gitlab账号对应一个私钥和**。
一、新建user1的SSH key
ssh-****** -t rsa -C "[email protected]"
Enter file in which to save the key (/Users/Administrator/.ssh/id_rsa): /c/Users/Administrator/.ssh/id_rsa_user1
将.ssh/id_rsa_user1.pub文件打开,复制里面的公钥,到gitlab/github的ssh中
将**添加到SSH agent中
ssh-add ~/.ssh/id_rsa_user1
二、新建user2的SSH key
创建:ssh-****** -t rsa -C "[email protected]"
Enter file in which to save the key (/Users/Administrator/.ssh/id_rsa):/Users/Administrator/.ssh/id_rsa_user2
将.ssh/id_rsa_user2.pub文件打开,复制里面的公钥,到gitlab/github的ssh中
将**添加到SSH agent中
ssh-add ~/.ssh/id_rsa_user1
三、编辑/创建.ssh/config
# GitLab.com server
Host user1
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa_user1
# GitLab.com server
Host user2
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa_user2
四、测试是否成功
ssh -T [email protected]
ssh -T [email protected]
如果成功,就进行下一步,否则重试上面几个步骤
五、克隆项目
同理克隆项目2的时候:
欢迎 start.https://github.com/MrGaoGang/