Specify an SSH key for git push for a given domain

I have the following use case: I would like to be able to push to [email protected]:gitolite-admin using the private key of user gitolite-admin, while I want to push to [email protected]:some_repo using ‘my own’ private key. AFAIK, I can’t solve this using ~/.ssh/config, because the user name and server name are identical in both cases. As I mostly use my own private key, I have that defined in ~/.ssh/config for [email protected]. Does anyone know of a way to override the key that is used for a single git invocation?

(Aside: gitolite distinguishes who is doing the pushing based on the key, so it’s not a problem, in terms of access, ownership and auditing, that the user@server string is identical for different users.)

18 Answers
18

Leave a Comment