This guide describes how to install and use ClusterSSH on Ubuntu 22.04/Ubuntu 20.04. ClusterSSH is a cluster administration tool that allows system admins to manage multiple Linux servers from a single administration console for example running a similar command across a cluster of systems. When run, ClusterSSH opens up an administration console and xterm terminals on every other host in a cluster. Any text typed into the administration console is replicated to all terminals. One can also type into all the windows directly. This tools is so handy in the sense that it reduces the laden of having to run similar commands on each host.
Install and Use ClusterSSH on Ubuntu 22.04/Ubuntu 20.04
Install ClusterSSH on Ubuntu 22.04/Ubuntu 20.04
ClusterSSH is available on the default Ubuntu repositories. Thus you can simply install by running the command below;
apt update
apt install clusterssh nux-tools
ClusterSSH Command Line Syntax and Options
cssh
is the command line ClusterSSH utility. The command line syntax for cssh command is;
cssh [-a '<command>'] [-K <seconds>] [-q] [-c '<filename>'] [-x <cols>] [-C '<filename>'] [--debug [[...] || <INTEGER>]] [-d] [-e '<[user@]<host>[:port]>'] [--fillscreen] [-f '<font>'] [-h] [-L '[tag]'] [-H] [-o '<STRING>'] [-p <port>] [-Q] [-y <rows>] [-s] [-r '<filename>'] [-t '<STRING>'] [-g] [-T '<title>'] [-u] [-?] [-A] [-l '<username>'] [-v]
You can get a description of the command line options from the help page;
cssh -h
Options: Some of these options may also be defined within the configuration file. Default options are shown as appropriate. --action '<command>', -a '<command>' Run the command in each session, e.g. "-a 'vi /etc/hosts'" to drop straight into a vi session. --autoclose <seconds>, -K <seconds> Number of seconds to wait before closing finished terminal windows. --autoquit, -q Toggle automatically quitting after the last client window has closed (overriding the config file). --cluster-file '<filename>', -c '<filename>' Use supplied file as additional cluster file (see also "FILES"). --cols <cols>, -x <cols> Number of columns --config-file '<filename>', -C '<filename>' Use supplied file as additional configuration file (see also "FILES"). --debug [[...] || <INTEGER>] Enable debugging. Either a level can be provided or the option can be repeated multiple times. Maximum level is 9. --dump-config, -d Dump the current configuration in the same format used by the $HOME/.clusterssh/config file. --evaluate '<[user@]<host>[:port]>', -e '<[user@]<host>[:port]>' Display and evaluate the terminal and connection arguments to display any potential errors. The <hostname> is required to aid the evaluation. --fillscreen Resize terminal windows to fill the whole available screen --font '<font>', -f '<font>' Specify the font to use in the terminal windows. Use standard X font notation such as "5x8". --help, -h Show basic help text and exit --list '[tag]', -L '[tag]' List available cluster tags. Tag is optional. If a tag is provided then hosts for that tag are listed. NOTE: format of output changes when using "--quiet" or "-Q" option. --man, -H Show full help text (the man page) and exit --options '<STRING>', -o '<STRING>' Specify arguments to be passed to ssh when making the connection. NOTE: options for ssh should normally be put into the ssh configuration file; see "ssh_config" and $HOME/.ssh/config for more details. Default: -x -o ConnectTimeout=10 --port <port>, -p <port> Specify an alternate port for connections. --quiet, -Q Do not output extra text when using some options --rows <rows>, -y <rows> Number of rows --show-history, -s Show history within console window. --tag-file '<filename>', -r '<filename>' Use supplied file as additional tag file (see also "FILES") --term-args '<STRING>', -t '<STRING>' Specify arguments to be passed to terminals being used. --tile, -g Toggle window tiling (overriding the config file). --title '<title>', -T '<title>' Specify the initial part of the title used in the console and client windows. --unique-servers, -u Toggle connecting to each host only once when a hostname has been specified multiple times. --usage, -? Show synopsis and exit --use-all-a-records, -A If a hostname resolves to multiple IP addresses, toggle whether or not to connect to all of them, or just the first one (see also config file entry). --username '<username>', -l '<username>' Specify the default username to use for connections (if different from the currently logged in user). NOTE: will be overridden by <user>@<host>. --version, -v Show version information and exit Arguments: The following arguments are supported: [user@]<hostname>[:port] ... Open an xterm to the given hostname and connect to the administration console. The optional port number can be used if the server is not listening on the standard port. <tag> ... Open a series of xterms defined by <tag> in one of the supplementary configuration files (see "FILES"). Note: specifying a username on a cluster tag will override any usernames defined in the cluster.
Manage Multiple Linux Systems using ClusterSSH
ClusterSSH can be used to manage multiple systems via SSH as already mentioned.
In this setup, I have three Linux systems;
- The management Ubuntu system with cssh command installed
- Debian and Rocky Linux remote systems to manage using ClusterSSH.
Example administrative usage of ClusterSSH
SSH to Multiple Servers at Once using ClusterSSH
To login to multiple servers via SSH using ClusterSSH, simply run the command below;
cssh -l kifarunix 192.168.58.43 192.168.59.38
When you run the command, two terminals are launched including a small screen that enables you to type the commands in to the shells launched.
See the screenshot below (I have just re-arranged the screens to make it easy to see on the screenshot).

As usual, if it is the first time you are login into a server as a user, you are prompted on whether to continue with authentication. in most case, the answer would be yes. Thus, type yes in the small screen provided. Whatever you type is propagated across all terminal windows launched.
If the passwords for the user used for remote login is not same, then click each system terminal and enter the password individually.
To run similar commands on the remote hosts, just type the commands on the small window.
You can also login to multiple servers using different users via CSSH;
cssh [email protected] [email protected]
To login, click on the terminal for each host and enter the respective user password.

As much as you can run same commands on multiple servers after login, it is also possible to login and automatically run specific commands on all remote hosts;
This can be achieved via the cssh --action 'command'
, or -a 'command'
command line option.
For example, to login and automatically run a ping test;
cssh -a 'ping -c 4 google.com' [email protected] [email protected]

Configure ClusterSSH Clusters
There are two kinds of cluster configurations that you can create;
- the user-specific and the
- The user-specific configuration can be set on the user’s home directory
- The configuration file is
~/.clusterssh/config
. - The cluster file is
~/.clusterssh/clusters
.
- global cluster configuration.
- while the global configuration sets system-wide cluster.
- The configuration file is
/etc/clusters
.
The clusters enable you define remote systems to access.
To use user specific cluster configuration, simply create the ~/.clusterssh/clusters
file and update it as follows;
vim ~/.clusterssh/clusters
The format is as follows:
<tag> [user@]<server>[:port] [user@]<server>[:port] [...]
For example, if you have multiple servers to login to e.g from Web apps, database servers, you would have an entry like;
web [email protected] [email protected]
database [email protected]
So you can simply login to Web servers like;
cssh web
You can also update the CSSH configuration options by updating the file;
cat ~/.clusterssh/config
Default options;
#auto_close=5 #auto_quit=yes #auto_wm_decoration_offsets=no #cols=-1 #command= #command_post= #command_pre= #comms=ssh #console=console #console_args= #console_position= #external_cluster_command= #external_command_mode=0600 #external_command_pipe= #extra_cluster_file= #extra_tag_file= #fillscreen=no #hide_menu=0 #history_height=10 #history_width=40 #key_addhost=Control-Shift-plus #key_clientname=Alt-n #key_history=Alt-h #key_localname=Alt-l #key_macros_enable=Alt-p #key_paste=Control-v #key_quit=Alt-q #key_retilehosts=Alt-r #key_user_1=Alt-1 #key_user_2=Alt-2 #key_user_3=Alt-3 #key_user_4=Alt-4 #key_username=Alt-u #lang=en #macro_hostname=%h #macro_newline=%n #macro_servername=%s #macro_user_1=%1 #macro_user_1_command= #macro_user_2=%2 #macro_user_2_command= #macro_user_3=%3 #macro_user_3_command= #macro_user_4=%4 #macro_user_4_command= #macro_username=%u #macro_version=%v #macros_enabled=yes #max_addhost_menu_cluster_items=6 #max_host_menu_items=30 #menu_host_autotearoff=0 #menu_send_autotearoff=0 #mouse_paste=Button-2 #rows=-1 #rsh=rsh #rsh_args= #screen_reserve_bottom=60 #screen_reserve_left=0 #screen_reserve_right=0 #screen_reserve_top=0 #send_menu_xml_file=/home/kifarunix/.clusterssh/send_menu #sftp=sftp #sftp_args= #show_history=0 #ssh=ssh #ssh_args= #telnet=telnet #telnet_args= #terminal=xterm #terminal_allow_send_events=-xrm '*.VT100.allowSendEvents:true' #terminal_args= #terminal_bg_style=dark #terminal_colorize=1 #terminal_decoration_height=10 #terminal_decoration_width=8 #terminal_font=6x13 #terminal_reserve_bottom=0 #terminal_reserve_left=5 #terminal_reserve_right=0 #terminal_reserve_top=5 #terminal_size=80x24 #terminal_title_opt=-T #title=CSSH #unique_servers=0 #unmap_on_redraw=no #use_all_a_records=0 #use_hotkeys=yes #use_natural_sort=0 #user= #window_tiling=yes #window_tiling_direction=right
For more information on configuration, see FILES section of man cssh.
man cssh
/etc/clusters, $HOME/.clusterssh/clusters These files contain a list of tags to server names mappings. When any name is used on the command line it is checked to see if it is a tag. If it is a tag, then the tag is replaced with the list of servers. The format is as follows: <tag> [user@]<server>[:port] [user@]<server>[:port] [...] e.g. # List of servers in live live admin1@server1 admin2@server2:2022 server3 server4 All comments (marked by a #) and blank lines are ignored. Tags may be nested, but be aware of using recursive tags as they are not checked for. Extra cluster files may also be specified either as an option on the command line (see "cluster-file") or in the user's $HOME/.clusterssh/config file (see "extra_cluster_file" configuration option). NOTE: the last tag read overwrites any pre-existing tag of that name. NOTE: there is a special cluster tag called "default" - any tags or hosts included within this tag will be automatically opened if nothing is specified on the command line. /etc/tags, $HOME/.clusterssh/tags Very similar to clusters files but the definition is reversed. The format is: <host> <tag> [...] This allows one host to be specified as a member of a number of tags. This format can be clearer than using clusters files. Extra tag files may be specified either as an option (see "tag-file") or within the user's $HOME/.clusterssh/config file (see "extra_tag_file" configuration option). NOTE: All tags are added together /etc/csshrc & $HOME/.clusterssh/config This file contains configuration overrides - the defaults are as marked. Default options are overwritten first by the global file, and then by the user file. NOTE: values for entries do not need to be quoted unless it is required for passing arguments, e.g. "terminal_allow_send_events="-xrm '*.VT100.allowSendEvents:true'"" should be written as "terminal_allow_send_events=-xrm '*.VT100.allowSendEvents:true'" auto_close = 5 Close terminal window after this many seconds. If set to 0 will instead wait on input from the user in each window before closing. See also --autoclose and --no-autoclose auto_quit = 1 Automatically quit after the last client window closes. Set to 0 to disable. See also --autoquit comms = ssh Sets the default communication method (initially taken from the name of the program, but can be overridden here). console_position = <null> Set the initial position of the console - if empty then let the window manager decide. Format is '+<x>+<y>', i.e. '+0+0' is top left hand corner of the screen, '+0-70' is bottom left hand side of screen (more or less). external_cluster_command = <null> Define the full path to an external command that can be used to resolve tags to host names. This command can be written in any language. The script must accept a list of tags to resolve and output a list of hosts (space separated on a single line). Any tags that cannot be resolved should be returned unchanged. A non-0 exit code will be counted as an error, a warning will be printed and output ignored. If the external command is given a "-L" option it should output a list of tags (space separated on a single line) it can resolve extra_cluster_file = <null> Define an extra cluster file in the format of /etc/clusters. Multiple files can be specified, separated by commas. Both ~ and $HOME are acceptable as a reference to the user's home directory, e.g. "extra_cluster_file = ~/clusters, $HOME/clus" key_addhost = Control-Shift-plus Default key sequence to open AddHost menu. See "KEY SHORTCUTS" for more information. key_clientname = Alt-n Default key sequence to send cssh client names to client. See "KEY SHORTCUTS" for more information. key_localname = Alt-l Default key sequence to send hostname of local server to client. See "KEY SHORTCUTS" for more information. key_paste = Control-v Default key sequence to paste text into the console window. See "KEY SHORTCUTS" for more information. key_quit = Control-q Default key sequence to quit the program (will terminate all open windows). See "KEY SHORTCUTS" for more information. key_retilehosts = Alt-r Default key sequence to retile host windows. See "KEY SHORTCUTS" for more information. key_username = Alt-u Default key sequence to send username to client. See "KEY SHORTCUTS" for more information. macro_servername = %s macro_hostname = %h macro_username = %u macro_newline = %n macro_version = %v Change the replacement macro used when either using a 'Send' menu item, or when pasting text into the main console. macros_enabled = yes Enable or disable macro replacement. Note: this affects all the "macro_*" variables above. max_addhost_menu_cluster_items = 6 Maximum number of entries in the 'Add Host' menu cluster list before scrollbars are used max_host_menu_items = 30 Maximum number of hosts to put into the host menu before starting a new column menu_host_autotearoff = 0 menu_send_autotearoff = 0 When set to non-0 will automatically tear-off the host or send menu at program start mouse_paste = Button-2 (middle mouse button) Default key sequence to paste text into the console window using the mouse. See "KEY SHORTCUTS" for more information. rsh = /path/to/rsh ssh = /path/to/ssh telnet = /path/to/telnet Set the path to the specific binary to use for the communication method, else uses the first match found in $PATH rsh_args = <blank> ssh_args = "-x -o ConnectTimeout=10" telnet_args = <blank> Sets any arguments to be used with the communication method (defaults to ssh arguments). NOTE: The given defaults are based on OpenSSH, not commercial ssh software. NOTE: Any "generic" change to the method (e.g., specifying the ssh port to use) should be done in the medium's own config file (see "ssh_config" and $HOME/.ssh/config). screen_reserve_top = 0 screen_reserve_bottom = 60 screen_reserve_left = 0 screen_reserve_right = 0 Number of pixels from the screen's side to reserve when calculating screen geometry for tiling. Setting this to something like 50 will help keep cssh from positioning windows over your window manager's menu bar if it draws one at that side of the screen. terminal = /path/to/xterm Path to the X-Windows terminal used for the client. terminal_args = <blank> Arguments to use when opening terminal windows. Otherwise takes defaults from $HOME/.Xdefaults or $HOME/.Xresources file. terminal_chdir = 0 When non-0, set the working directory for each terminal as per 'terminal_chdir_path' terminal_chdir_path = $HOME/.clusterssh/work/%s Path to use as working directory for each terminal when 'terminal_chdir' is enabled. The path provided is passed through the macro parser (see the section above on 'macros_enabled'. terminal_font = 6x13 Font to use in the terminal windows. Use standard X font notation. terminal_reserve_top = 5 terminal_reserve_bottom = 0 terminal_reserve_left = 5 terminal_reserve_right = 0 Number of pixels from the terminal's side to reserve when calculating screen geometry for tiling. Setting these will help keep cssh from positioning windows over your scroll and title bars or otherwise overlapping the windows too much. terminal_colorize = 1 If set to 1 (the default), then "-bg" and "-fg" arguments will be added to the terminal invocation command-line. The terminal will be colored in a pseudo-random way based on the host name; while the color of a terminal is not easily predicted, it will always be the same color for a given host name. After a while, you will recognize hosts by their characteristic terminal color. terminal_bg_style = dark If set to "dark", the terminal background will be set to black and the foreground to the pseudo-random color. If set to "light", then the foreground will be black and the background the pseudo-random color. If terminal_colorize is "zero", then this option has no effect. terminal_size = 80x24 Initial size of terminals to use. NOTE: the number of lines (24) will be decreased when resizing terminals for tiling, not the number of characters (80). terminal_title_opt = -T Option used with "terminal" to set the title of the window terminal_allow_send_events = -xrm '*.VT100.allowSendEvents:true' Option required by the terminal to allow XSendEvents to be received title = cssh Title of windows to use for both the console and terminals. unmap_on_redraw = no Tell Tk to use the UnmapWindow request before redrawing terminal windows. This defaults to "no" as it causes some problems with the FVWM window manager. If you are experiencing problems with redraws, you can set it to "yes" to allow the window to be unmapped before it is repositioned. use_all_a_records = 0 If a hostname resolves to multiple IP addresses, set to 1 to connect to all of them, not just the first one found. See also "--use-all-a-records"} use_hotkeys = 1 Setting to 0 will disable all hotkeys. use_natural_sort = 0 Windows will normally sort in alphabetical order, i.e.: host1, host11, host2. Setting to this 1 will change the sort order, i.e.: host1, host2, host11. NOTE: You must have the perl module Sort::Naturally installed. user = $LOGNAME Sets the default user for running commands on clients. window_tiling = 1 Perform window tiling (set to 0 to disable) window_tiling_direction = right Direction to tile windows, where "right" means starting top left and moving right and then down, and anything else means starting bottom right and moving left and then up NOTE: The key shortcut modifiers must be in the form "Control", "Alt" or "Shift", e.g. with the first letter capitalised and the rest lower case. Keys may also be disabled individually by setting to the word "null". $HOME/.clusterssh/send_menu This (optional) file contains items to populate the send menu. The default entry could be written as: <send_menu> <menu title="Use Macros"> <toggle/> <accelerator>ALT-p</accelerator> </menu> <menu title="Remote Hostname"> <command>%s</command> <accelerator>ALT-n</accelerator> </menu> <menu title="Local Hostname"> <command>%s</command> <accelerator>ALT-l</accelerator> </menu> <menu title="Username"> <command>%u</command> <accelerator>ALT-u</accelerator> </menu> <menu title="Test Text"> <command>echo "ClusterSSH Version: %v%n</command> </menu> </send_menu> Submenus can also be specified as follows: <send_menu> <menu title="Default Entries"> <detach>yes</detach> <menu title="Hostname"> <command>%s</command> <accelerator>ALT-n</accelerator> </menu> </menu> </send_menu> Caveats: There is currently no strict format checking of this file. The format of the file may change in the future If the file exists, the default entry (Hostname) is not added The following replacement macros are available (note: these can be changed in the configuration file): %s Hostname part of the specific connection string to each client, minus any username or port %u Username part of the connection string to each client %h Hostname of server where cssh is being run from %n "RETURN" code NOTE: requires XML::Simple to be installed
And that is it on how to install and use ClusterSSH on Ubuntu 22.04/Ubuntu 20.04.
Other Tutorials
Install and Setup ZSH and Oh-My-Zsh on Ubuntu 20.04/Ubuntu 22.04