Managing Multiple GitHub Accounts on a Single Machine: A Professional Guide

6 min readNov 16, 2023

Efficiently juggling multiple GitHub accounts on a single machine is a common challenge for developers and professionals. In this guide, we’ll explore the best practices and strategies to seamlessly work with multiple GitHub accounts, ensuring a smooth and organized development workflow.

Photo by Juliana Romão on Unsplash

Alright, so picture this — you’ve got two GitHub accounts, one for work vivek-professional and one for your personal projects vivek-personal. Now, let’s make your Machine a smooth talker with both of them.

Here’s how we’re gonna set it up. 🚀

This logic is like a friendly chameleon — it can adapt to more than just two accounts. So, whether you’ve got three, four, or a whole army of GitHub accounts, this setup’s got your back. Flexibility at its finest! 🌐💻

1. Create SSH keys for all accounts

First, make sure your current directory is your .ssh folder

  • For Linux Environment
$ cd ~/.ssh
  • For Windows environment
  • For Mac environment

Syntax for generating a unique ssh-key for an account:

ssh-keygen -t rsa -C "your-email-address" -f "github-username"


-C stands for comment to help identify your ssh key

-f stands for the file name where your ssh key gets saved

ssh-keygen -t rsa -C "" -f "vivek-professional"
ssh-keygen -t rsa -C "" -f "vivek-personal"

So, here comes the drama — after you hit that command, the terminal’s gonna ask for the passphrase Now, you’ve got options. You can go the mysterious route and leave it empty like a secret agent keeping things low-key. Or, you can give it a passkey with personality, something that makes you chuckle. Because guess what? Before it struts down the runway of remote commands, it’s gonna ask for that passphrase with a twinkle in its code. So, choose your passphrase adventure! 🔐😄

Now after adding keys , in your .ssh folder, a public key and a private will get generated.

When the keys step into the scene, they’ve got their own style. The public key, being the outgoing type, throws on a “.pub” extension like it’s going to a party. On the flip side, the private key keeps it cool and simple, no extra frills — just the name you fed it after that ‘-f’ trick. Think of it as a power duo: one likes the limelight, and the other is the behind-the-scenes MVP. Teamwork, but make it keys! 🔐💼

2. Active your ssh-agent and add ssh-keys

Alright, buckle up! You’ve got the keys in hand, but they’re like VIPs waiting for their turn to shine. So, what’s the next move? You gotta use them into the SSH Agent party! run the command in the terminal of the same folder.

eval `ssh-agent -s`

Think of the SSH Agent as the bouncer holding the guest list. Until your keys get on that list, they’re stuck at the door, eager to join the action. So, time to add those keys to the SSH Agent and let the real tech soirée begin! 🎉🔑

ssh-add ~/.ssh/vivek-professional
ssh-add ~/.ssh/vivek-personal

3. Add ssh-key to GitHub

Time to give our keys a passport to the GitHub world! Here’s the game plan:

  • Track Down Your Public Key:

Hunt down that party-loving “.pub” file — your public key. It’s the one ready to make connections.

  • Copy-Paste Mastery:

Do the copy-paste hustle with your public key.

vim ~/.ssh/
vim ~/.ssh/


cat ~/.ssh/
cat ~/.ssh/


pbcopy < ~/.ssh/
pbcopy < ~/.ssh/
  • Swing By GitHub:

Take a stroll through your GitHub. Wander into Settings > SSH and GPG keys > New SSH Key

  • Paste the public key on Github

Click on New SSH Key and paste your copied key. your copied public key and give it a Title of your choice.

  • Repeat the Steps:

Don’t play favorites! If you’re juggling more GitHub accounts, give each of them a slice of your key action. Same steps, different GitHub accounts.

Step 4: Create a config file and make host entries

Alright, let’s set the stage for our keys with a cozy config file. Follow these steps:

  • Navigate to the SSH Config File:

Head to your trusty terminal and find your SSH config file. If it doesn’t exist yet, create one in your home directory: ~/.ssh/config

# create, if not exist
touch config

# open config file
nano ~/.ssh/config
  • Add host

Now, let the magic happen. For each GitHub account, toss in a snazzy host entry like this:

# GitHub - vivek-professional
Host vivek-professional
User git
IdentityFile ~/.ssh/vivek-professional

# GitHub - vivek-personal
Host vivek-personal
User git
IdentityFile ~/.ssh/vivek-personal

NOTE: Feel free to customize those names, make them yours!

Step 5: Let’s grab stuff from GitHub using different accounts! 🌟

Alright, the stage is set, and now it’s showtime! Picture this: you’re about to clone a super cool repository using one of your shiny GitHub accounts. Let’s make it happen:

  • Create a Fresh Project Nest: Find a cozy spot on your computer and create a brand new folder for your project. Jump into it through the terminal because, well, we’re keeping it fancy.
mkdir YourAwesomeProject
cd YourAwesomeProject
  • Get Ready for the Magic: Now, let’s say we’re plucking a gem from your personal GitHub treasure trove. If you named it TestRepo brace yourself for this command:
git clone

Swap out YourUsername with, you guessed it, your actual GitHub username.

  • Witness the Clone: Hit Enter, and watch the magic unfold. You’re not just copying files; you’re summoning the repository into your project folder.

And just like that, you’ve cloned a piece of the GitHub universe into your very own project realm! 🚀✨

Step 6: Final Step

Time to make sure your commits and pushes have the right passport stamps! Here’s the secret handshake:

  • Configure Your Identity: It’s like telling each repository, “Hey, it’s me, you!” For your office repository:
git config ""
git config "Vivek professional"

And for the personal touch:

git config ""
git config "vivekumar08"

Pick the right combo for each repository.

  • Set the Remote Origin: Now, let’s teach your project where to send those magical pushes. For the personal vibe:
git remote add origin

git remote add origin

Now, your project knows where to call home.

  • Command Center: With everything set up, you’re the captain of this Git ship. Use these commands to send your changes:
git push

git pull

Bonus Tips:

Tip 1: If you face executing the pull or push command Permission denied (publickey).
fatal: Could not read from remote repository.

then you can add ssh-key to the agent again

if the agent is not active then it will show

Could not open a connection to your authentication agent.

And now you know what step you have to perform 😉

Tip 2: If your existing working directories not working with ssh

git remote remove origin

then you will be able to set a new origin, if you read till the end then you know at what step you are


You’ve just unlocked the GitHub wizard level! 🧙‍♂️ Now, with your machine all set up to dance with multiple GitHub accounts, and your keys holding VIP passes, you’re in control. Cloning repositories is like grabbing the coolest toys from GitHub and configuring identities and remotes is your secret sauce for making sure everything goes where it should.

Remember, the tech journey is all about making things work seamlessly, and you’ve just aced that. So, whether you’re pushing code from your coding lair at the office or contributing to your personal passion project, you’re now the maestro orchestrating the GitHub symphony.

Keep coding, keep cloning, and keep rocking those repositories! 🚀🎉




A passionate Developer with innovative ideas into reality. With an experience in the MERN stack and cutting-edge Nextjs technology, dynamic approach to web dev.