Multi-Account GitHub SSH Workflow -
seamless push-pull from different accounts
without credential drama!
Step-by-Step: Multi-GitHub SSH Setup
Let’s say:
You have two GitHub accounts:
personal-account
work-account (or whichever was added as a collaborator)
You want to keep separate SSH keys for each.
1. Generate a New SSH Key for the Second GitHub Account
When prompted to save the key, give it a unique name (e.g., id_ed25519_work ):
Enter file in which to save the key: /Users/you/.ssh/id_ed25519_work
Now you have:
Private key: ~/.ssh/id_ed25519_work
Public key: ~/.ssh/id_ed25519_work.pub
2. Add That SSH Key to Your GitHub Account
Copy the public key:
pbcopy < ~/.ssh/id_ed25519_work.pub # macOS
# or
cat ~/.ssh/id_ed25519_work.pub # then copy manually
Go to GitHub → Settings → SSH and GPG Keys → New SSH key
Add it to the account that has repo access (the one added as a collaborator).
3. Create a ~/.ssh/config File
This lets you specify which key to use for which GitHub account.
Edit or create the config:
vim ~/.ssh/config
Then add this:
# Personal GitHub
Host github-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
# Work GitHub
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
Adjust the paths if your key files are named differently.
4. Clone the Repo Using the Matching Host Alias
Instead of cloning from
[email protected]:... , you use your custom host:
git clone git@github-work:user/reponame.git
That github-work alias makes Git use the correct SSH key behind the scenes.
5. Push and Pull with No Issues
Once it’s cloned like that, Git will always use the right key — and you can have both
personal and work accounts happily coexist.
Bonus: Using Multiple Git Emails per Repo
If your Git author email is different for each account, you can configure per-repo
email:
cd reponame
git config user.name "Ishaan Shrivastava"
git config user.email "[email protected]"