TIL: Multiple git users on one machine.

Published March 02, 2026

The company where I work recently changed from on prem GitHub to GitHub Enterprise Cloud. This means that instead of going to github.corp.com we now need to go to github.com. This caused a small issue for me - I want to have access to my personal GitHub account also. There's things I keep there (like this site, and my environment settings, among other things) that I want to have access to on my work computer. Shouldn't be too hard. Just set up 2 configs in the .ssh/config - one for personal and one for corporate:


Host github-personal
  User personal
  HostName github.com
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_ed25519

Host github.com
  HostName github.com
  User corporate
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_ed25519_corporatee_ghe

So that's what I did. And for a while it worked well. Until a few months ago (about a month after the transition) when I wasn't able to properly access my work repos. I went to IT and we figured something out and got it working again (after a couple of hours) and it had been fine. Until today. Today I went to sync the repo for this site and had the reverse issue - SSH was choosing the corporate user and not the personal one. So I did some digging and I found this post on Stack Overflow. So TIL that to have SSH use the correct definition I need to add


  IdentitiesOnly yes

to each of the entries for the same site in the .ssh/config file. Once I added that, everything started working as expected.


Previous: You can get a patch of PR