SSH keys for Multiple Accounts in Github

I have multiple Github accounts and some of these are collaborator in others. I don’t like to write passwords every time I push, so I set up SSH keys for my accounts. But Github (understandably) doesn’t accept a key in more than one account. (Otherwise how can it know?)

But there is a way to use .ssh/config file to use different keys for different target urls.

# Personal account, - the default config
Host github.com
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa

# Work Account
Host work.github.com
   HostName github.com
   User git
   IdentityFile ~/.ssh/id_rsa_work

Now you can create another ssh key in ~/.ssh/id_rsa_work and add it to your account. When you configure a repo, you need to specify git@work.github.com:user/repo as the repository address rather than git@github.com:user/repo.