Git SSH using multiple account (GitLab)

The key is in ~/.ssh/config, here you can give aliases for every user on same host. SSH Key on each GitLab account must be already set up.


Host user1.gitlab.com
  Hostname gitlab.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_user1

Host user1.gitlab.com
  Hostname gitlab.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_user2

Testing:


$ ssh -T git@user1.gitlab.com
Welcome to GitLab, @user1!


$ ssh -T git@user2.gitlab.com
Welcome to GitLab, @user2!