ssh on multiple servers Using cluster ssh

Cluster SSH opens terminal windows with connections to specified hosts and an administration console. Any text typed into the administration console is replicated to all other connected and active windows. 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.

Introduction

What is ClusterSSH and what is it used for?

Ever had to make the same change on more than one Linux/unix server? Find it annoyingly painful to keep repeating the exact same commands again and again and again?

This tool addresses exactly this problem. You run a utility (cssh) providing a number of server names as parameters, and then xterms opens up to each server with an extra “console” window. Anything typed into the console is replicated into each server window (so, for examples, you can edit the same file on N machines at the same time, or run the same commands with the same parameters across those servers).

It is also possible to type into the server windows directly, or temporarily disable replication to one or more of the servers through the “Hosts” menu.

Difference between ClusterSSH and “cssh”

The utility itself is called “cssh”. The project name is ClusterSSH. The project is not called “cssh” because when the project was first registered on SourceForge a project already existed using that name (“C sharp” unix shell).

Install cluster ssh on debian

#apt-get install clusterssh

Configuration Files

This /etc/clusters file is cluster tag database. Contains a list of tags and hostnames, in the form

<tag> [<username>@]hostname [...]

Newlines and comments (delimited with a #) are ignored.

Cluster definitions can also be added to the $HOME/.csshrc file

This /etc/csshrc file is Global configuration file, sourced by all users. Can be generated by:

cssh -u > /etc/csshrc

$HOME/.csshrc

Per user configuration file. Can be generated by:

cssh -u > /etc/csshrc</tt>

To add a cluster definition to this file, use the following format

cluster_tag1 = server1 server2 user@server3
cluster_tag2 = server4 server5
clusters = cluster_tag1 cluster_tag2

Be aware of using “reserved names” and no check is currently performed for them.

Using Cluster SSH

If you want to perform the same command on the three servers one, two, & three use the following command

# cssh one two three

This will open three consoles, one for each server, over an ssh connection, and one little console to type your command.

Sponsored Link

Leave a comment

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