1

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).

2
  • Would using ssh-agent make that problem go away? It can hold info about several identities.
    – tink
    Nov 8, 2012 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, 2012 at 12:51

1 Answer 1

0

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:

#!/bin/bash
key=$1
[[ "$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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .