Let's take an example where you have two gitlab repositories one for personal account and one for work and both have different account users.
@my-personal -> Personal Account gitlab
@my-work -> Work Account gitlab
Step 1:
Generate the ssh key for each account : give names for your key
ssh-keygen -t rsa -b 4096 -f ~/.ssh/my-personal
ssh-keygen -t rsa -b 4096 -f ~/.ssh/my-work
Step 2
cd ./ssh
update the config file
# Personal SSH key for GitLab
Host gitlab-personal
HostName gitlab.com
User git
IdentityFile ~/.ssh/my-personal
# Nthexam SSH key for GitLab
Host gitlab-work
HostName gitlab.com
User git
IdentityFile ~/.ssh/my-work
Step 3
Upload these keys into respective account settings in gitlab its in
User -> Profile -> SSH keys
https://gitlab.com/-/profile/keys
Once you upload the public keys then you can test
Step 4
Test connections in terminal
ssh -T git@gitlab-personal
-> output Welcome to GitLab, @my-personal
ssh -T git@gitlab-work
-> output Welcome to GitLab, @my-work
Step 5
To clone you need to give the host name alias
git clone git@gitlab-personal:{ssh_url}
git clone git@gitlab-work:{ssh_url}
If gitlab clone ssh url is for personal account
[email protected]:my-development/backend/mydev.git
Then change it to
git@gitlab-personal:my-development/backend/mydev.git
Step 6
You can set the remote origin as suggested by @demetere._ so that you don't have to type the host name every time
You can also set this rmeote origin if you creating the fresh repository and if cloning the existing repository you cna give the host name once.
You can test the new remote origin as
git remote --verbose
origin [email protected]:my-development/backend/mydev.git (fetch)
origin [email protected]:my-development/backend/mydev.git (push)