Remember when we authenticated github on our shell using ssh keys? Remember ? Well, imagine if you authenticated both your
personal and work keys in your PC and you have projects belonging to each account
which need to be worked on. Here is how to fix it:
Specify the path to your private key file when using the ssh command. Like this:
ssh -T -i ~/.ssh/id_rsa_account1 git@github.com # For account 1
ssh -T -i ~/.ssh/id_rsa_account2 git@github.com # For account 2
Replace the file names with actual paths to your private key files.
Mine are id_rsa
for Jaarabytes and hi
for xh3rking
Also, (this is a long stretch) but you can also do the following,
Update remote urls for the repositories, for the personal repository:
git remote set-url origin git@github.com-personal:username/repository.git
for the work repository:
git remote set-url origin git@github.com-work:username/repository.git
Then verify the configuration, for personal account:
git clone git@github.com-personal:username/repository.git
for the work repository:
git clone git@github.com-work:username/repository.git
If errors are encountered, you can debug by running:
ssh -vT git@github.com-personal
ssh -vT git@github.com-work
The commands above give a verbose output on the ssh connections being made. Good luck, you will need it. I mean look at this,