ClusterSSH Run Command On Multiple Servers At Same Time – CSSH

SSH is called as – Secure Shell and used to connect to remote server in encrypted manner and run commands do required things. Using SSH we can’t run single command in multiple servers yet the same time. My requirement is to run command multiple servers at the same time so that administrator job will become easy some times. ClusterSSH is used to run the command on multiple servers at the same time. cssh

ClusterSSH (CSSH) Run Command Multiple Servers

  • Required Graphical User Interface to run
  • It also uses SSH protocol to connect remote machine
  • Easy way to run similar commands in multiple servers
  • Useful for Emergency Tasks

Installing and configuring cssh command in Linux / Unix

$ sudo apt-get install clusterssh  #--For Ubuntu System

# yum install clusterssh -y   #--RHEL/Centos Systems

Clusterssh packages are not available with core list (within installation DVD / ISO) you have to setup EPEL Repository and run yum install command

$ cch server1 server2
$ cssh admin@server1 root@server2
Clusterssh GUI window

Clusterssh GUI window

Note: When your trying to login to server1 and server2 users passwords should be same

$ cssh

Type cssh without providing any arguments it will open one window from there you can add number of hosts manually

add host to clusterssh

add host

provide host name

provide host name

Create Cluster(s) (Just Like Group)

We have an main configuration file /etc/clusters edit the file and define cluster so that instead of providing number of server name you can use cluster name to connect all the servers

/etc/clusters file is an global level configuration which will effect each user

We can also configure user level settings using ~.cssh or ~.clusterssh

clusteers = testservers
testservers =

Now connect to configured cluster(s) name

$ cssh -l arkit testservers

As per above command arkit is an UserName. Immediately it will open multiple windows connected to multiple servers now run command multiple servers 

Most i see this cssh command is useful on setting up passwordless connection to multiple hosts on single go

cssh command run command on multiple servers at same time

Open up a session to 4 servers

$ cssh server1 server2 server3 server4

Open up a session to a cluster of servers identified by the tag ‘web1’ and give the controlling window a specific title, where the tag is defined in one of the default configuration files

$ cssh -T 'Web Server1' web1

Connect to different servers using different login names.
NOTE: This can also be achieved by setting up appropriate options in the configuration files. Do not close the console when the last terminal exits.

$ cssh administrator@server1 admin@server2

Open up a cluster defined in a non-default configuration file

$ cssh -c $HOME/cssh.custom

Override the configured/default port to use 2020 instead

$ cssh -p 2020 server1 server2

Shortcut Keys

  • Ctrl+Shift++(Plus) – Open’s “Add Host(s) or Cluster(s)” Dialog box.
  • Alt+n – Paste in the Host Name Part of the specific connection string to each client
  • Alt+1 – Paste in the Host Name of the server cssh is ebing run on
  • Alt+q – Quit the program and close all connections
  • Alt+r – Re-tile all the client windows
  • Alt+u – Paste in the User Name for the connection

There are many other options to configure things using cssh utility

Download Advanced Shell Scripting Book Freely in PDF format

Thanks for your wonderful Support and Encouragement


Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *