Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I see from the ssh_config man page that you can share connections to host@user using ControlPath and ControlMaster.
Is there any way to do this opportunistically for each combination of local user, remote user, and remote host? So that the first connection to testuser@remotelaptop is shared when you ssh into it the second time and the first is still running?

(I use ssh keys. I'm not sure if that would make it easier or harder).

share|improve this question

1 Answer 1

up vote 6 down vote accepted

From the ssh_config man page:

ControlMaster
    ...
    Two additional options allow for opportunistic multiplexing: try
    to use a master connection but fall back to creating a new one if
    one does not already exist.  These options are: “auto” and
    “autoask”.  The latter requires confirmation like the “ask”
    option.

So if you configure ssh with ControlMaster auto, it will attempt to connect to use an existing SSH session, falling back to creating a new master connection if that fails.

So a configuration like the following is probably what you're after:

ControlMaster auto
ControlPath ~/.ssh/control/%r@%h:%p
share|improve this answer
    
Nice! Now why didn't I scroll down just a little bit in my terminal and see that part of the man page? :) –  Azendale Sep 19 '11 at 20:17

Your Answer

 
discard

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.