1 min read

Setup Multiple SSH Keys in Windows

Configure which SSH key to use with your GIT repositories.

Photo by Jaye Haych on Unsplash

When using the same computer for different purposes, it is likely that we want to use different SSH keys. For example, we may want to push to GitHub or GitLab with a specific SSH key using our work key whereas on other repositories we may want to use our personal key.

On Windows, there is fortunately an easy way to specify which key we want to use. However, we need a small setup first, so let us get to it.


First, let us assume that we already have at least two different SSH keys.

For example:

  • id_rsa and id_rsa.pub (name of default key)
  • personal_id_rsa and personal_id_rsa.pub

In this case, by default we want to use our work SSH key. Therefore we name our work SSH key using the default name. For the personal one, we will prepend personal_.

These keys are all located under C:\Users\<username>\.ssh.


In the same .ssh folder there must be a config text file (yes, without extension). If the file does not exist, we can create an empty config.txt file and remove the extension.

Following, we proceed to create our entries for configuring which key we want to use in which case.

# Work key for GitHub
Host work.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
# Personal key for GitHub
Host personal.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/personal_id_rsa

# Personal key always for GitLab
Host gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/personal_id_rsa

Let me explain what these three examples do:

  1. When cloning a repository from GitHub, instead of using the normal address like git@github.com:xyz/xyz.git, we should instead use git@work.github.com:xyz/xyz.git. This will automatically tell GIT we want to use the work SSH key for this repository.
  2. Similarly, we can use git@personal.github.com:xyz/xyz.git to specify that we want to use the personal SSH key.
  3. If we just want to associate a service with a specific SSH key, we can directly do it if we do not prepend anything as we did before with work.github.com or personal.github.com. In this case we have gitlab.com and all cloned repositories will use the personal SSH key.


And that is it! We have seen how to handle multiple SSH keys on Windows and how to easily specify which one to use when cloning GIT repositories.

Thanks for reading!

If you found this article interesting, share it!

Follow my journey

Get the latest updates in your inbox 📨

    No spam. Unsubscribe as your heart desires.