Using multiple GitHub accounts from a single macOS/Linux account


Let’s say you’re stuck working from home due to an ongoing apocalypse. Let’s say that you use separate GitHub accounts for personal projects vs. work (for one of any number of reasons), and that when you’re working from home you’re using a personal computer. Let’s say that for Reasons it’s not feasible for you to juggle multiple user accounts on said computer, and you need to be able to access both of your GitHub accounts without a lot of hassle.

The main problem is that GitHub ties your ssh key to your account (out of necessity), but all connections to GitHub are via the master account, so there’s no easy way to differentiate which key to use at runtime.

So, here’s how I managed to set things up so that I could select a GitHub account on a per-shell basis.

Read more…