0%
Managing Multiple GitHub Accounts on the Same Machine (Personal + Work Setup Guide)
FEATURED

Managing Multiple GitHub Accounts on the Same Machine (Personal + Work Setup Guide)

Learn how to use both personal and work GitHub accounts on the same computer without authentication conflicts. This step-by-step guide shows how to configure SSH keys and Git settings so each repository uses the correct account.

Saransh Pachhai
Saransh Pachhai
3 min read7 viewsMarch 15, 2026
gitgithubsshmultiple-accountsdeveloper-tools
Share:

Why This Guide Exists

Many developers use two GitHub accounts:

  • One for office or company work

  • One for personal projects

At first everything seems fine, but sooner or later something strange happens:

  • A commit in your personal project shows your company email

  • A work repository uses your personal account

This happens because Git is using the same SSH key and global configuration for every repository.

The solution is simple: create separate SSH keys and configure Git to use them correctly.

Once this is set up, you can easily manage both accounts on the same machine without any confusion.


Quick Rule to Remember

Office Work

git@github.com:company/repo.git

Personal Projects

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

The github.com-personal host tells Git to use your personal SSH key.


One-Time Setup

You only need to do this once, and then everything will work automatically.


1. Create SSH Keys

First, create two SSH keys:

  • One for work

  • One for personal use

Office Account

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "your.name@company.com"

Personal Account

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

After running these commands you will have:

~/.ssh/id_ed25519
~/.ssh/id_ed25519.pub

~/.ssh/id_ed25519_personal
~/.ssh/id_ed25519_personal.pub

The .pub files are public keys that need to be added to GitHub.


2. Add Keys to GitHub

Now connect each SSH key to the correct GitHub account.

Copy the office key:

cat ~/.ssh/id_ed25519.pub

Add it to your company GitHub account.

Next copy the personal key:

cat ~/.ssh/id_ed25519_personal.pub

Add it to your personal GitHub account.

You can add these in:

GitHub → Settings → SSH and GPG Keys


3. Create SSH Configuration

Now we configure your system to know which key belongs to which account.

Open the SSH config file:

nano ~/.ssh/config

Add this configuration:

# OFFICE Account (DEFAULT)
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519

# PERSONAL Account
Host github.com-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_personal

What This Does

  • github.com → uses your work account

  • github.com-personal → uses your personal account


4. Set Your Default Git Identity

Since most developers spend more time working on company projects, we usually set the office identity globally.

git config --global user.name "Your Office Name"
git config --global user.email "your.name@company.com"

Now your work repositories will automatically use this identity.


Daily Usage

Once everything is configured, using both accounts becomes very simple.


Office Projects

Clone repositories normally:

git clone git@github.com:company/project.git

Use Git as usual:

git push origin main
git pull origin dev

Git will automatically use your office SSH key.


Personal Projects

For personal repositories, use the personal host name.

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

Example:

git clone git@github.com-personal:john/my-portfolio.git

Now Git will use your personal SSH key.


Fix Personal Repository Identity (Optional)

Inside a personal project folder you can set your personal Git identity:

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

This ensures commits appear under your personal GitHub account.


Testing the Setup

You can verify everything works correctly.


Test Work Account

ssh -T git@github.com

It should show your company GitHub username.


Test Personal Account

ssh -T git@github.com-personal

It should show your personal GitHub username.


Check Repository Remote

If you ever want to confirm which account a repository is using:

git remote -v

Example outputs:

Office repository

git@github.com:company/project.git

Personal repository

git@github.com-personal:username/project.git

When You Join a New Company

If you change jobs, simply generate a new SSH key.

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_new -C "new.email@company.com"

Update your SSH config:

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_new

Your personal configuration stays the same.


Final Thoughts

Managing multiple GitHub accounts on the same machine might seem tricky at first.

But once you configure:

  • Separate SSH keys

  • A simple SSH config

  • Proper clone URLs

You can switch between work and personal projects effortlessly.

No more authentication issues, no more wrong commits — just a clean and organised development workflow.


Quick Commands Table

Purpose

Command

Clone work repo

git clone git@github.com:org/repo.git

Clone personal repo

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

Test connections

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

Check current remote URL

git remote -v

Fix local identity

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

Loading comments...

Designed & developed with❤️bySaransh Pachhai

©2026. All rights reserved.