wnd's weblog

SSH connection multiplexing

7 Apr 2020 00:22:25 FFR, software

OpenSSH has built-in connection multiplexing. I’ve been using SSH for two decades, and only now I realise SSH comes with connection multiplexing. See ssh_config option ControlMaster.

I use SSH daily. I create and use SSH tunnels daily. To name a few uses, I use SSH tunnels for database connections, HTTP connections, and for SSH connections. I used to connect to x11vnc over an SSH tunnel. I create tunnels that require two hops. However, never have I used SSH connection multiplexing. Until tonight.

Host foo
        Hostname        example.com
        ControlPath     /var/run/user/1000/%r@%h:%p
        ControlMaster   auto
        ControlPersist  10m

This simple config will /automagically/ start a master process on first connection to foo, and share that for future connections. Master is killed 10 minutes after the last client disconnect.

I am sure there are benefits in having dedicated process for each connection. I am sure there are drawbacks in connection multiplexing. For now, I’m just happy to learn something new.