dsh : a distributed shell

clusterA common problem when you deal with a pool of servers (clusters or server farms, you name it) is to execute the same command line on each server. It is usual to solve this with a “for” construct such as :

for i in server1 server2 ; do ssh $i "uname -a"; done

But this is basically re-inventing the wheel everytime. Here comes Distributed Shell (DSH).

DSH is a tool whose purpose is simply to execute a single command on a group of machines.

For a simple use, you first need to setup a machines.list file (either in /etc or /etc/dsh) which is simply a file with one hostname by line.

dsh will use either rsh, remsh or SSH to remotely execute the commands. Of course SSH is highly recommended as it is much more secure than the others.

This means that you will have to deploy your SSH public keys beforehand, so that SSH can login on the remote host without interactively typing a password.

Then running a command on multiple hosts is just a matter of something like :

dsh "uname -a"

Of course you can define groups of hosts, and use the “-c” option switch to launch the commands in parallel instead of one after the next.

Nice tool if you have a cluster (or a pool of servers) to administrate !

2 thoughts on “dsh : a distributed shell”

Leave a Reply

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