tl;dr デプロイツールによっては 同じサーバに SSH で何回もコマンドを実行することがある(ansible とか)。 コマンドごとに毎回コネクション(トンネル)を確立するとオーバーヘッドも大きくなる。 OpenSSH は $HOME/.ssh/config に次の設定を書くことで、接続を多重化(multiplex)することができる。 # $HOME/.ssh/config Host machine1 HostName machine1.example.org ControlPath ~/.ssh/controlmasters/%r@%h:%p ControlMaster auto ControlPersist 1h multiplex 前後の速度差 SSH を使ってリモートサーバで echo コマンドを実行した時の速度差を計測 before multiplex $ time ssh
![SSHの多重接続について](https://cdn-ak-scissors.b.st-hatena.com/image/square/8d71ff5111e05619a10d29bb40d7aebaa75c8fbc/height=288;version=1;width=512/https%3A%2F%2Fs0.wp.com%2Fi%2Fblank.jpg)