Effortlessly Toggle Between GitHub Profiles Using SSH

Raj Shah
2 min readOct 12, 2023

--

Many of us developers find ourselves navigating multiple GitHub accounts: one for professional use, another for personal endeavors, and sometimes even more for side gigs or freelance projects. The constant back-and-forth can become tedious, and there’s always the lurking danger of mistakenly committing code under the wrong profile. SSH keys are about to become your best friend, streamlining this process and eliminating those pesky login interruptions.

Step 1: Craft Your SSH Key
Kick off by generating an SSH key tailor-made for the account you’re focusing on:

ssh-keygen -t ed25519 -C "youremail@gmail.com"

This command will yield a public key named id_ed25519.pub. Grab its content and steer towards GitHub's user-friendly interface.

Step 2: Embed Key on GitHub

  • Venture to your personal GitHub dashboard via Settings.
  • Dive into the “SSH & GPG keys” section.
  • Click on the “New SSH key” button.
  • Infuse your key’s content, copied from id_ed25519.pub.

Step 3: Incorporate Key into the SSH Agent
Ensure your machine is well-acquainted with this key for every GitHub interaction:

ssh-add id_ed25519

Step 4: Test Drive Your Connection
Embark on a test run to ensure your new connection to GitHub is seamless:

ssh -T git@github.com

Anticipate a warm acknowledgment from GitHub, spotlighting your updated username. If you bump into a ‘Permission Denied’ hiccup, double-check that your SSH key is snugly integrated into GitHub and that your SSH agent is on its toes.

Step 5: Refresh Your Git Identity
Conclude by updating your Git credentials to match your current persona:

git config --global user.name “username”
git config --global user.email “email@gmail.com"

In Conclusion
With these steps under your belt, you’re poised for a smoother GitHub journey. No more fumbling with logins or fretting over mistaken commits. Have you had a whirl with this method before? Or perhaps you have other nifty strategies for juggling multiple GitHub accounts? We’re all ears! Share your insights and experiences in the comments below.

--

--