Sample Header Ad - 728x90

Is there a way to have an opportunistically shared SSH connection without blocking the local TTY session?

2 votes
1 answer
262 views
In my ~/.ssh/config, I have the ControlMaster auto setting enabled. It works pretty well for me, but there is one behaviour that irritates me that I’d like to eliminate. Let’s say I have two terminal emulator windows A and B. In window A, I invoke ssh to connect to a remote host, then I do the same in window B. Next, I type exit in window A to close the session. Although I have disconnected, the ssh process in window A does not exit to the local session because it has to wait for the process in window B to end its remote session as well: it has to keep the control socket running. I would rather have it so that when I disconnect in window A, I am immediately returned to the original local session from which I invoked ssh, while the session in window B keeps running. You may ask: well, which process should manage the control socket then? Ideally, I’d like it to be a dedicated third process running under the supervision of the user systemd instance, that automatically disconnects when there are no more sessions running. But I’d also accept a more hacky approach with a lingering background process. And I would rather avoid launching the control socket master manually. It should start automatically as soon as I open the first session. Is this possible to do?
Asked by user3840170 (1889 rep)
Mar 27, 2021, 01:12 PM
Last activity: Mar 27, 2021, 01:41 PM