DEVELOPMENT Jan 29, 2026

Git Multi SSH Keys (Work & Personal) — Quick Tutorial

If you juggle work and personal repos, one default key isn’t enough. This setup keeps identities separated and prevents the "permission denied" surprises.

1. Generate SSH Keys

Personal

ssh-keygen -t ed25519 -C "personal@email.com" -f ~/.ssh/id_ed25519_personal

Work

ssh-keygen -t ed25519 -C "work@company.com" -f ~/.ssh/id_ed25519_work

2. Add Public Keys to Git Provider

cat ~/.ssh/id_ed25519_personal.pub
cat ~/.ssh/id_ed25519_work.pub

Quickly copy to clipboard (macOS):

pbcopy < ~/.ssh/id_ed25519_personal.pub
pbcopy < ~/.ssh/id_ed25519_work.pub

Add each key to:

  • GitHub / GitLab / Bitbucket → SSH Keys

3. Configure ~/.ssh/config

Quick edit with nano:

nano ~/.ssh/config
# Personal
Host github.com-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_personal
  IdentitiesOnly yes

# Work
Host github.com-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_work
  IdentitiesOnly yes

4. Test SSH Identity

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

5. Clone Repo Using Correct Identity

Personal

git clone git@github.com-personal:username/repo.git

Work

git clone git@github.com-work:company/repo.git

6. Add / Fix Remote for Existing Repo

Set Personal Remote

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

Set Work Remote

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

Verify:

git remote -v

7. Set Git Identity Per Repo

Personal

git config user.name "Your Name"
git config user.email "personal@email.com"

Work

git config user.name "Your Work Name"
git config user.email "work@company.com"

8. Verify Which Key Is Used (Debug)

GIT_SSH_COMMAND="ssh -v" git fetch origin

Look for:

Offering public key: ~/.ssh/id_ed25519_personal

9. Common Errors

Permission denied (publickey)

  • SSH key not added to provider
  • Wrong Host used in remote URL
  • IdentityFile mismatch

Fathur

Written by Fathur

Building products at the intersection of strategy and code. Product Manager who codes, Developer who understands users.