How to use multiple SSH keys with Github

And do this without using ssh-agent, that has a number of problematic security constructs (e.g. key forwarding).

Create your keys

ssh-keygen -t rsa -b4096  -f ~/.ssh/github_key1_rsa -C some-id1 -N ""
ssh-keygen -t rsa -b4096  -f ~/.ssh/github_key2_rsa -C some-id2 -N ""

Login into github and add the ~/.ssh/github_key1_rsa.pub and key2 to the appropriate accounts, under “settings” -> “ssh and gpg keys”

Add these identities into your ~/.ssh/config

Host github.com-acc1
	HostName github.com
	User git
    PubkeyAuthentication yes
	IdentityFile ~/.ssh/github_key1_rsa

Host github.com-acc2
HostName github.com
User git
PubkeyAuthentication yes
IdentityFile ~/.ssh/github_key2_rsa

Then update your upstream origin

git remote set-url origin github.com-acc1:myname1/Repo.git
git remote set-url origin github.com-acc2:myname2/Repo.git
Based off the Stack theme.