Send commands to multiple SSH sessions with Terminator

Streamline management of multiple machines with this handy tool.
111 readers like this.
FreeDOS

Opensource.com

Terminator is a single-window split-screen terminal multiplexer that allows you to send identical keystrokes to all terminals at once. This means you can SSH into any number of machines, run the same commands simultaneously, and see them all at the same time.

Install Terminator with: sudo apt install terminator

Then, when you open the app, it’s just a regular terminal window. You can use it on its own, or right-click somewhere to split the screen, vertically or horizontally. Then you can type into each one individually, or choose the option to broadcast to all windows or a group.

Obviously, great care must be taken when running commands on multiple machines; it’s easy to make a mistake. You must also be aware that running the same command can take varying amounts of time to complete, or can have different outputs. If you type an SSH command to connect to several different servers and hit Enter on them all together, some may require you to type "yes" to continue if you haven’t connected to it before. Typing "yes" and Enter on a machine probably won’t do any harm (actually, try it and see!), but it’s not a habit to get into. If you need to control windows individually, you can turn off "broadcasting" and turn it back on when you’re ready.

I often use Terminator for managing piwheels build servers.

It’s a very handy tool for certain jobs—good to know about!

What to read next
Tags
User profile image.
Ben is a software engineer for BBC News Labs, and formerly Raspberry Pi's Community Manager. He's into Linux, Python and all things open source! Follow Ben on Twitter @ben_nuttall.

3 Comments

interesting! Worth trying

I do similar things with GNU parallel.

I put a command for each machine, one per line in a text file, as "ssh machine -t bash -ci 'COMMAND'"

And then I run parallel :::: commandfile.txt

This means I can do the same operation even if different machines require different commands.

Nice! I was looking for a way to scale a process that I want to run...this looks perfect for the job.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.