Note: The question originally asked about running commands simultaneously on several machines - hence my first solution was using Tmux. This is probably not suited for 100s of machines at once.
Use Tmux (fully or partially manual) or write a script (fully automatic).
It is advised to get familiar with the Tmux commands and shortcuts - preferably by making your own config. But here's how to do it (manually) with default config.
Start new session:
tmux new -s mysession
Split the window into X panes:
- Ctrl + b, then % (split horizontal)
- Ctrl + b, then " (split vertical)
Navigate around the panes with Ctrl + b, then Arrow keys
On each pane, SSH into a different machine:
ssh user@host
Enter command mode:
- Ctrl + b, then :. Then type:
setw synchronize-panes
(now every command is sent to all panes)
Enter the command you wish to run:
sudo apt install -y firefox
This will now run via SSH on every machine.
You can also write a script that uses Tmux to connect to your list of IP's. And then you can run the commands manually in sync mode, or by the script also.
I'd say if you have 10s of machines, I would use Tmux. If you have 100s of machines, consider making this fully automated by a script.
Reference: Tmux Cheat Sheet.
ssh root@{host} sh -c "apt update && apt -y upgrade"
– Rinzwind Apr 11 '22 at 18:42