ClusterSSH: Manage Multiple SSH Sessions on Linux
ClusterSSH is a Cluster administration tool via SSH. It is used to control number of xterm windows via a single graphical console window to allow commands to be interactively run on multiple servers over an SSH connection. If you’re are a Linux administrator managing hundreds of machines, you may have chances to enter same command on many servers. To do that, you have to login to each server and should enter the command on each server. It is such a time consuming process. Using ClusterSSH, the commands typed in the administration console window will replicate to all servers. In simple words it is an excellent tool for making the same change on multiple servers at the same time.
sk@sk:~$ sudo apt-get install clusterssh
It will not be found in official repositories. So add EPEL repository and install clusterssh.
To add EPEL repository, enter the following command:
[root@server ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Now install ClusterSSH:
[root@server ~]# yum install clusterssh -y
Configuration is simple and straight forward. Create a ClusterSSH config file and define the clusters. For instance, I am managing two servers Ubuntu 13.04 server and CentOS 6 server from my Ubuntu 13.04 desktop. Here I use my cluster name as testcluster and ip address of both servers are 192.168.1.200 and 192.168.1.201 respectively.
First create a cluster config file as shown below:
sk@sk:~$ sudo nano /etc/clusters clusters = testcluster testcluster = 192.168.1.200 192.168.1.201
Save and exit the file. Here, testcluster is my cluster name. 192.168.1.200 is my CentOS 6 server IP address and 192.168.1.201 is my Ubuntu 13.04 server IP address. You can use hostnames instead.
Open up your terminal and run the following command. You must allow the port 22 through Firewall/Router to access the servers from any remote machines:
sk@sk:~$ sudo cssh -l root testcluster
The terminal windows of all servers will be automatically opened as shown below.
Enter the Root password on both servers SSH sessions. Now you will see that two servers are logged-in through SSH.
Alternatively you can launch it using individual hostname or IP address instead of cluster name:
sk@sk:~$ sudo cssh -l root 192.168.1.200 192.168.1.201
The small window called CSSH(2) is the administration console window of ClusterSSH. The commands typed in the administration console will reflect on both servers.
For example, I type hostname command and hit enter on the ClusterSSH administration console. As you seen in the below screen shot, the command hostname is performed automatically on both servers at the same time and displays the result.
Kind note: If you type any wrong commands or inappropriate commands in CSSH admin console, it will perform on all servers simultaneously and will lead you into trouble. Double check the commands before hit enter. Enjoy!