Reputation: 79
I am trying to find out if there is a way to connect with multiple ubuntu machines and install updates simultaneously.
Ideally, if I enter a command "sudo apt-get update" from one machine, it should execute in all the ubuntu machines that I am connected to.
I looked at TMUX but not sure if that would be appropriate. Also found apt-cacher but connecting with other systems using their IP remains unclear.
any help and reference will be appreciated.
Upvotes: 3
Views: 1943
Reputation: 326
Yes, tmux is capable of connecting to multiple machines and running commands simultaneously. Connect to each host in a pane and use the 'synchronize-panes' window option to send each pane the same keyboard input simultaneously.
The command looks like:
:setw synchronize-panes
Following is a complete example, let's create a window with 3 panes, each logged into a different server:
$ tmux new -s 'update packages' 'ssh admin@host1' \; split-window -h 'ssh admin@host2' \; split-window -h 'ssh admin@host3' \; select-layout even-horizontal
Once you have logged into the servers being upgraded, on the tmux prompt (C-b :), enter 'setw synchronize-panes'
Now everything you type will be input to all panes
Note: As mentioned in another post, tools like 'pssh' and 'csshX' may be better suited for this purpose.
Upvotes: 3
Reputation: 919
Yes, with parallel-ssh provided in pssh you can just do that. It executes a command in parallel on all of the machines you want. Here is the man page : http://manpages.ubuntu.com/manpages/lucid/man1/parallel-ssh.1.html
Install it with apt-get install pssh
Or
apt-get install parallel-ssh
Upvotes: 2