Speeding up OpenSSH sessions with multiplexing

When you’re about to establish an SSH connection to a new host, it usually takes a few seconds before the session is loaded. If you open multiple SSH sessions to the same host, the overhead starts to sum up and you’re waiting for the connection. This might not be a big issue for normal/manual use, but if you’re doing automation via SSH, or a lot of git push/pull operations, this could become a PITA.

Enable OpenSSH multiplexing via config

OpenSSH has a really neat multiplexing feature implemented, which unfortunately is disabled by default. To enable it, you’ve to update your SSH config with the Control* options:

Host example.confirm.ch
ControlMaster auto
ControlPath ~/.ssh/control-%r@%h:%p
ControlPersist 15m

The ControlMaster  option defines whether ssh is listening for control connections and what to do with them. If you set it to auto , ssh will create a control socket at the ControlPath  at the first connection attempt, and then use it automatically for future connections to that host. You can also set it to autoask , so that ssh will ask you about confirmation. The control socket will be existing for ControlPersist  amount of time. You can also set ControlPersist  to yes , so that the multiplexing connection is open in the background indefinitely, until you close it manually.

Control open multiplexing sessions

You can control the multiplexing connections via ssh command.

To check for a multiplexing connection:

ssh -O check example.confirm.ch

To stop a multiplexing connection:

ssh -O stop example.confirm.ch

Manually open a multiplexing session

To manually establish a multiplexing connection:

ssh -M -S ~/.ssh/control-dbarton@example.confirm.ch:22 example.confirm.ch

For future SSH connections, you just have to specify the socket:

ssh -S ~/.ssh/control-dbarton@example.confirm.ch:22 example.confirm.ch


  • 8 ball pool

    You can also set it to autoask so that ssh will ask you about confirmation…

  • respite care

    I saw a lot of website but I believe this one contains something special in it.