Skip to main content

Command Palette

Search for a command to run...

How to Connect and use multiple github account on Single Deveice?

Published
β€’3 min read
Z

🧐 Are you facing challenges like slow website performance, poor user experience, cross-browser issues, and difficulty integrating with back-end systems, all while trying to manage business growth without a streamlined digital solution? πŸ€” Are you struggling to reach a wider audience, improve customer engagement, and stay competitive without a web app, while dealing with inefficient operations, limited scalability, and missed revenue opportunities? πŸš€ Build a web app to expand reach, improve engagement, and streamline operations for growth. βš™οΈ Optimize performance, enhance user experience, and integrate systems with a smooth, scalable solution. πŸ‘¨β€πŸ’» I am Zia-Ur-Rehman a MERN Developer with experience in building scalable and high-performing web applications that solve buisness Problems. I worked with the startup to Help their clients by developing highly scalable webApps to make their global buisness mangable with one click across globe. βœ… Frontend Development to create responsive, user-friendly interfaces that solve the problems of your audience. βœ… Figma to Next.js Functional App transforming your designs into interactive, high-performance Web apps. βœ… Web App Development to expand your reach and improve customer engagement.βœ… Performance Optimization for faster load times and seamless user experience.βœ… Cross-Browser Compatibility ensuring your app works perfectly everywhere.βœ… Backend Integration to streamline operations and boost business efficiency.
If you have an idea that will capture market share, why are you waiting? πŸš€ DM me today or email me (emailtozia0@gmail.com) and get started!

1️⃣ Introduction: Why Multiple GitHub Accounts Exist

Many developers have:

  • πŸ‘€ Personal GitHub account

  • 🏒 Company GitHub account

  • πŸ§‘β€πŸ’» Client / Freelance GitHub account

GitHub allows this.
Your computer, however, needs to be taught how to switch between them safely.

That is exactly what this guide does.


2️⃣ How GitHub Knows β€œWho You Are”

There are two ways GitHub identifies you:

  • Asks for login repeatedly

  • Breaks with multiple accounts

  • Easy to misconfigure

  • Uses cryptographic keys

  • No passwords

  • Works perfectly with multiple accounts

πŸ‘‰ We will use SSH only.


3️⃣ What Is SSH? (Simple Explanation)

Think of SSH like a house key:

  • πŸ—οΈ Private key β†’ stays on your computer

  • 🧾 Public key β†’ given to GitHub

When GitHub sees your key:

β€œYes, I recognize this person.”

Each GitHub account gets its own key.


4️⃣ How Multiple Accounts Work on One Computer

Your computer:

  • Stores multiple SSH keys

  • Uses a map (config file) to decide which key to use

  • Automatically picks the correct identity per project

πŸ“Œ You never log in and out manually.


5️⃣ Preparing Your System

βœ… Windows

  • Install Git for Windows

  • Use PowerShell or Git Bash

  • SSH is already included

βœ… Ubuntu / Linux

sudo apt update
sudo apt install git openssh-client

Verify:

git --version
ssh -V

6️⃣ Creating SSH Keys (Most Important Step)

One account = one key

Never reuse keys.

πŸ”Ή Windows & Ubuntu (same command)

ssh-keygen -t ed25519 -C "personal@email.com"

Press Enter to accept default location.

Repeat for second account:

ssh-keygen -t ed25519 -C "work@email.com"

Rename keys when asked:

id_ed25519_personal
id_ed25519_work

7️⃣ Adding Keys to GitHub

For each account:

  1. GitHub β†’ Settings β†’ SSH & GPG Keys

  2. Click New SSH Key

  3. Copy the .pub file content:

     cat ~/.ssh/id_ed25519_personal.pub
    
  4. Paste β†’ Save


8️⃣ Teaching Your Computer Which Key to Use

Create config file:

~/.ssh/config

Add:

# Personal account
Host github-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_personal

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

🧠 This is the secret sauce.


9️⃣ Using Repositories (Real Example)

Personal repo:

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

Work repo:

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

Git now:

  • Uses the correct key

  • Uses the correct GitHub account

  • Never mixes identities


πŸ” Mini Case Study

Scenario:
Zia works at a company and freelances at night.

  • Company laptop β†’ work GitHub

  • Same laptop β†’ personal projects

Using SSH config:
βœ… No login issues
βœ… No permission errors
βœ… No accidental pushes to wrong account


⚠️ Common Beginner Mistakes

❌ Using HTTPS + SSH together
❌ One SSH key for all accounts
❌ Wrong key permissions
❌ Forcing wrong key path

βœ… This guide avoids all of them.


🌟 Best Practices (Professional Level)

  • One key per account

  • Clear key names

  • Backup .ssh folder securely

  • Never share private keys

  • Use SSH config always


πŸ› οΈ Quick Troubleshooting Checklist

ssh-add -l
ssh -T git@github.com
git remote -v

If SSH works but Git fails β†’ wrong key mapping.