Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 two SSH keys 'personal' and 'work'.

With them I need to connect to a service:

The keys are linked to two accounts on, however in SSH they both have to use the same user 'user'. Thus I can't use ~/.ssh/config and 'Host's to route the two keys to the correct accounts. As a result, I put the 'work' key into ~/.ssh/config using Host, and comment it out when wanting to do stuff with my 'personal' key.

My question is, is there a better way to handle this?

When I interact with that service, I will source anyway so having some environment variable in there to handle the routing would be ideal, but I can't find a way to change, for example, the ssh config file path, using environment variables.

I don't use ssh directly but rather through a 3rd party tool.

Is there such a variable?

I'm on Linux (Ubuntu).

share|improve this question
up vote 5 down vote accepted

You could have two entries in ~/.ssh/config and have whatever settings you need:

Host work
User workid

Host personal
User homeid

Then you can do ssh work and ssh personal.

Basically the trick is: the Host part does not have to be a real DNS host name, it can be whatever you want.

share|improve this answer
I should have added: I can't actually use ssh directly. It's done through a 3rd party command line tool. – ojii Nov 10 '11 at 19:28
Does that mean you have no control over the command? Because you could also use ssh -F myfile to override $HOME/.ssh/config – Kevin Panko Nov 10 '11 at 19:32
This is the tool I'm using:, specifically this bit of code: So I cannot directly modify the ssh party, but the environment of it. – ojii Nov 10 '11 at 19:33
You could modify $HOME but that's going to cause its own problems. I recommend changing that python code to use ssh -F if you set something in the environment. – Kevin Panko Nov 10 '11 at 19:39
just to clarify, -F /path/to/other/ssh-config? As in -F points to the config file? EDIT: Nevermind, did the man ssh thing and found out. Thanks – ojii Nov 10 '11 at 19:41

You must log in to answer this question.

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