I recently had to make the same change on multiple web servers - all configured in the same way and running Ubuntu. My work colleague suggested me to use tool called ClusterSSH. According to documentation: "This tool is intended for (but not limited to) cluster administration where the same configuration or commands must be run on each node within the cluster. Performing these commands all at once via this tool ensures all nodes are kept in sync.".
I provide below steps how to install and configure this tool on Ubuntu 12.04LTS desktop.
- sudo apt-get update
- sudo apt-get install clustershh
Basic use of ClusterSSH:
To use ClusterSSH open Linux terminal and type: cssh - it opens a window. Go to Hosts -> Add Host(s) or Cluster(s) and type details of servers you want to connect to: username@server1 username@server2 etc. Click Add button - you can see that connections to specified servers have been opened. Click on window that was opened when we typed cssh and start typing command - you should see that what you are typing is sent to all opened connections. If you want to do something just in one opened connection click it and start typing.
If you want to read about all configuration settings please refer to: man cssh. if you have list of servers that you always want to connect to you can add two lines to configuration file of cssh to make this process easier. Configuration file is located in your home directory: ~/.csshrc - edit this file and add below lines at the end of the file:
- my-servers=username@server1 username@server2
What above lines do: I create new cluster called "my-servers" and in the next line I specify list of servers to which I want to connect when I type in terminal cssh my-servers. ClusterSSH checks if the tag my-servers exists and replace it be defined value (in our case list of servers username@server1 username@server2).