
- Generate your ssh key:
ssh-keygen -t ed25519 -C "user@email.com"
2. Add your ssh keys in Gitlab under settings
3. Edit your ~/.ssh/config file with following content:
# User1 Account Identity
Host username1.gitlab.com
Hostname gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/key_path.pub
# User2 Account Identity
Host username2.gitlab.com
Hostname gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/key_path.pub
4. Test if you're able to connect to both accounts:
ssh -T git@username1.gitlab.com
Expected Output: welcome to gitlab, username1!
ssh -T git@username2.gitlab.com
Expected Output: welcome to gitlab, username2!