Configuring a Different SSH Key per Git Repository [updated]

Usecase: you need to manage multiple git accounts (e.g. private and work), with each their own SSH key.

Example: you use host Bitbucket privately, and your firm starts using Bitbucket as well. Or client B has set up an account for you, which uses the same host you’ve already used.

Fabian Keller has a simple way of working with this. Check out https://www.fabian-keller.de/blog/configuring-a-different-ssh-key-per-git-repository/

Initial clone with alternative key

If you want to make that initial call, without already having set up a local git repo, use the following call:

git clone git@bitbucket.org:my-work/my-repo.git --config core.sshCommand="ssh -F ~/.ssh/config-bitbucket-my-work"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.