Manage access to multiple GitHub accounts with ssh — local development

pi314tech
3 min readNov 15, 2021

If you are a software programmer or developer, it is quite common that you will have a work-related GitHub account as well as a personal GitHub account. This article will help you to access multiple GitHub accounts from your workstation with ease.

I use a macOS for development, so all the examples and commands are based on macOS but should work on any linux based OS.

Step 1 : Generate ssh keys for Github accounts

First, generate the ssh key and add it to ssh key agents. Before following the recommended article in Github, the one thing to keep in mind is the file name for the key pair. My recommendation is to save the public/private key pair for each of the accounts with different, easily identifiable names. So while saving the file, save with github prefix. For example, my .ssh folder looks like this

github_id_rsa.pub
github_id_rsa
github_ce_id_rsa.pub
github_ce_id_rsa

So my personal GitHub public/private pair key has github prefix while my work account has github_ce a prefix, to easily identify.

github_id_rsa.pub => public key
github_id_rsa => private key [You will never need to share this to anyone and keep it private]

Step 2: Configure ssh config file

If you are regularly connecting to remote machines or repos, you will already be using ssh config file. In this…

--

--

pi314tech

Technology enthusiast, lifelong learner, developer, photographer and travel blogger