Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to setup an ssh group key used for publishing to a remote git repository.

As git (as well as I presume many other programs) don't allow defining a flag lag ssh -i the information which key is going to be used comes from the defaults or what is defined in ~/.ssh/config

This would require a new administration task for users that need to have this ability (i.e. add the proper entries in their ~/.ssh/config file).

Is there any way I could spare this effort? I haven't been able to locate any environment variable that would be read by OpenSSH as that would be a solution (by creating a wrapping script that does what is required).

share|improve this question
Would using ssh-agent make that problem go away? It can hold info about several identities. – tink Nov 8 '12 at 18:57
@tink: Thanks that is a good idea, it's hard to keep the user environment clean after that, but it works. – estani Nov 9 '12 at 12:51
up vote 0 down vote accepted

So the answers is as follows (thanks tink):

Using an ssh-agent to hold the key will always work. For that you could encapsulate the call in a script:

[[ "$SSH_AGENT_PID" ]] || eval $(ssh-agent)
ssh-add $key

#...the rest of the script...

In the particular case of git theres a GIT_SSH environment variable that points to the command that will be called instead of ssh. So it's possible to issue ssh with the -i flag.

Just to warn you that this is a proof of concept, you need to asure the environment is not affected after loading the script (i.e. if an agent was there and the key wasn't loaded you need to remove the key, if no agent was present, remove the agent, etc)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.