This question would be simple if I ask it as a use case. I have two SSH keys on my computer
- personal_id_rsa
- company_id_rsa
And I have two different user accounts on bitbucket.org. One of them is my personal account and the other is my company account. I have N number of repositories on my PC as well. Some of them has to be linked with my personal account and some other repos with the company account. There is no repositories that has to be linked to both the accounts. I have set the Identityfile inside the ~/.ssh/config
to something like below.
Host *.bitbucket.org
IdentityFile ~/.ssh/company_id_rsa
And whenever I want to push something to my personal repos, I change the config file to something like below.
Host *.bitbucket.org
IdentityFile ~/.ssh/personal_id_rsa
And now, it becomes quite an inconvenience to edit the file whenever I want to make a git push
. I was just thinking if I could just pickup one of the keys on the fly, when I push, it would have been a lot easier. Is there any way to do so?
I came across this question which explains a similar use case, but that is not the exact use case here.