CalcSnippets Search
Git 3 min read

Multiple GitHub Accounts on One Mac With SSH Config Is Easier Than the Workarounds

A practical macOS SSH guide for developers who use multiple GitHub accounts, covering separate keys, SSH config aliases, and how to stop personal and work repositories from colliding.

Why this gets messy quickly: if one Mac talks to both personal and work GitHub accounts, the default SSH story stops being enough. Without explicit config, the machine tends to offer the wrong key at the wrong time and make authentication feel random.

The right mental model

You are not really configuring “two GitHub logins” inside Git. You are configuring how SSH chooses identities for different connection targets.

That means the fix is usually not a Git command first. It is an SSH configuration step.

Generate separate keys

Example:

ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519_personal
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519_work

Then add the public keys to the corresponding GitHub accounts.

Create SSH config aliases

In ~/.ssh/config:

Host github-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_personal
  AddKeysToAgent yes
  UseKeychain yes

Host github-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_work
  AddKeysToAgent yes
  UseKeychain yes

Now you have two logical SSH targets that both point to GitHub but use different identities.

Why the remote URL matters

For a personal repo:

git remote set-url origin git@github-personal:yourname/repo.git

For a work repo:

git remote set-url origin git@github-work:company/repo.git

That alias is the whole trick. It tells SSH which identity block to apply.

Why people think the setup failed

Usually one of these is the issue:

  1. the remote still points to plain github.com
  2. the key was added to the wrong account
  3. the wrong private key is loaded
  4. the config file has a typo in the host alias

This is why copying keys alone is not enough. The remote URL and SSH aliasing have to agree.

A useful verification step

Test each alias directly:

ssh -T git@github-personal
ssh -T git@github-work

That tells you whether SSH identity selection is behaving before Git remotes add another layer of confusion.

Final recommendation

If one Mac needs to talk to multiple GitHub accounts, stop hoping the default identity selection will stay lucky. Separate the keys, alias the hosts, and make the remote URL declare which identity it expects. That is cleaner than juggling HTTPS credentials or wondering why the wrong account keeps appearing.

Once it is configured, the setup usually feels more obvious than the workarounds people use before they finally decide to fix it properly.

That is a good sign you solved the right problem.

The best environment fixes usually make the workflow feel more boring, not more clever.

That is a compliment in engineering, not a drawback.

Boring workflows are usually the ones teams can repeat successfully.

That repeatability is what makes the SSH setup worth doing cleanly.

You fix it once and stop paying the confusion tax later.

That is a strong trade for any machine that juggles both personal and work repositories.

It turns an annoying recurring problem into a solved one.

That kind of permanent cleanup is rare enough to be worth doing.

It gives one laptop a much clearer Git identity model.

Sources

Keep reading

Related guides