Skip to content

Different ssh keys for different accounts#

It might be a common case that you have multiple accounts (personal and professional), and you want to use different ssh keys for different github accounts, as does not allow same ssh key for different accounts with "Key is already in use" error.

To achieve this, you could follow this tutorial:

  1. Generate ssh keys for each account. For e.g. ~/.ssh/id_rsa and ~/.ssh/id_rsa_pro.
  2. Create a ~/.ssh/config file to specify which ssh key to use for which github account.

    IdentityFile ~/.ssh/id_rsa
    User copdips
    # The HostName is still, but the host here is, this is the key point.
    # You can change it to whatever you want
    IdentityFile ~/.ssh/id_rsa_pro
    User copdips-pro
  3. Git clone the repositories by replacing in the git clone ssh url with the ssh alias defined in ~/.ssh/config. Say the pro ssh clone url is:, than you need to rewrite it to to be able to use the ssh key ~/.ssh/id_rsa_pro defined in ~/.ssh/config.


In Chrome (so as to Edge), there's an extension called MultiLogin that allows you to use multiple accounts (for e.g. personal and professional accounts) across different tabs in the same browser instance. So you do not need to keep two browser instances opened at the same time. In Firefox, you even have a better extension called Firefox Multi-Account Containers.