2. Add the SSH Public Key into the respective accounts
3. Set up configuration file ~/.ssh/config with both accounts
# ACCOUNT 1, - the default config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/KEY1
# ACCOUNT 2
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/KEY2
4. Clone using the alias for the Github Link
git clone git@github.com:USER_NAME/GITHUB_REPO_NAME.git
or
git clone git@github.com-work:USER_NAME/GITHUB_REPO_NAME.git
Note: You will have to change only github.com to the alias you have set up
Additionally, if you need to test which account connects where use the following commands:
ssh -T git@github.com # Note this is Account 1 from ~/.ssh/config
# or
ssh -T gith@github.com-work # Note this is Account 2
Note: If you have set a different HOST parameter, you will have to use that one
As long as you have set up the SSH Keys correctly and the configuration file you should be able to clone the repositories successfully and the output should look like this: