Use another key in git
Sometimes you may want to use git via ssh but with different ssh keys than other repositories. For example you may have corporative and hove bitbucket account, and bitbucket will not allow you use same pub key with both accounts.
So you need to run ssh-keygen
and generate a new key (e.g. ~/.ssh/id_rsa_private
), then add it to another bitbucket account.
But when you run git it will still use your default ssh key (if not configured another default will be ~/.ssh/id_rsa
).
But we can switch the default key using -i
ssh option.
Change dir to the repo and run next:
echo export GIT_SSH_COMMAND=\"ssh -i ~/.ssh/id_rsa_private\" > ./gitize
Then before working with repo go to its dir and run
source gitize
You ready to go!