Using Personal vs Work GitHub Accounts
This guide helps you access your personal GitHub account from your work terminal, while keeping it completely separate from your work GitHub account.
✅ Step-by-Step Instructions
1. Generate SSH Key for Personal GitHub
ssh-keygen -t ed25519 -C "your-personal-email@example.com" -f ~/.ssh/id_ed25519_personal
2. Add Your Personal Key to the SSH Agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_personal
Your work key (
~/.ssh/id_ed25519
) is typically already managed by your system or ssh-agent.
3. Add the Public Key to Your Personal GitHub
cat ~/.ssh/id_ed25519_personal.pub
Go to GitHub SSH Key Settings and add your personal key.
4. Edit ~/.ssh/config
to Define Both Accounts
# Work GitHub (default key)
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
# Personal GitHub (alias with separate key)
Host github-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
IdentitiesOnly yes
5. Clone Personal Repositories Using Alias
git clone git@github-personal:your-username/your-repo.git
6. Set Git Identity for Personal Repositories
git config user.name "Your Personal Name"
git config user.email "your-personal-email@example.com"
This ensures your commits use your personal identity only in that repo.
🧠 Bonus (Optional): Shell Alias for Personal Git Commands
Add to your ~/.zshrc
or ~/.bashrc
:
alias git-personal='GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519_personal" git'
Then clone like this:
git-personal clone git@github.com:your-username/repo.git