Skip to content

OpenSSH

Enable connection multiplexing

The SSH protocol allows multiplexing multiple "channels" over a single session (TCP connection). A channel can be a shell, a file transfer, a forwarded port, etc. Multiplexing allows to reuse an existing connection for new channels, saving time for the connection setup.

With SSH confg file, the three options that begin with Control are used to enable multiplexing:

Host *
  ControlMaster auto
  ControlPath /tmp/sshcontrol-%C
  ControlPersist 1d

Note that %C is a hash of the local username, the remote hostname, port and username, and does not include other elements. Notably, it does not include the identity file, so if you try to connect to the same host with different public keys, you will end up reusing the same connection and the wrong key will be used. The impact is most pronounced when using a bastion host that identifies the user by the key, and the user has multiple keys for different purposes.