Skip to content
Advertisement

Running the same command on several ssh servers using tmux

Is is it possible to type a command once and run it over several servers connected via ssh using tmux?

Advertisement

Answer

What you are looking for might be “synchronize-panes”. With this option turned on, every keystroke is deliver to every pane of current window. Therefore, you can achieve your goal by:

  1. Split a tmux window into multiple panes and ssh to different servers in each panes

  2. turn on the aforementioned option. i.e.

    tmux set-window-option synchronize-panes

  3. type whatever command you intended.

In fact, I bond that option to Prefix + C-s in my tmux.conf:

bind-key C-s set-window-option synchronize-panes
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement