First, Generate two ssh keys called “id_rsa_project_a” and “id_rsa_project_b” as below.
ssh-keygen -t rsa -C "[email protected]"
Created ssh keys
~/.ssh/id_rsa_project_a ~/.ssh/id_rsa_project_b
Then add those keys as following.
ssh-add ~/.ssh/id_rsa_project_a ssh-add ~/.ssh/id_rsa_project_b
You can check your saved keys. Type as below
ssh-add -l
Then create a config file in ~/.ssh folder
sudo vim ~/.ssh/config
And edit as below
#Project A Host gitlab.com-project-a HostName gitlab.com User git IdentityFile ~/.ssh/id_rsa_project_a #Project B Host gitlab.com-project-b HostName gitlab.com User git IdentityFile ~/.ssh/id_rsa_project_b
Now you can use both projects with separate ssh keys 🙂
This is awesome. thanks a lot
?