Using a Distributed Shell (dsh) to Administer Multiple Workstations

287

Introduction

This is something I used to need a lot, that I dug out of my documentation to share.  These are steps to using dsh on ubuntu to administer multiple workstations.  This does not include instructions for setting up public/private key authentication in ssh, but these instructions work the best when this has been setup.  If you don’t setup ssh keys, you’ll end up having to type the root password for each machine you ssh into.

Setup

Installation

On Ubuntu, run this to install:

sudo aptitude install dsh

 

Configuration

Start by creating a new group of workstations.  I have several CentOS workstations, so I create a new file that contains all of these:

/etc/dsh/group/centos-workstations

# These are standard workstations conforming to the typical centos configuration
root@host1
root@host2
root@host3

Running Commands

You can run pretty much anything, but here’s an example:

dsh -g centos-workstations yum clean all
dsh -g centos-workstations yum -y upgrade

Some Shortcuts

I simplify matters even more by creating an alias

alias cent='dsh -g centos-workstations'

I add this to my .zshrc file.  This buys the the ability to run things like:

cent yum -y upgrade

Conclusion

I realize these instructions are a bit basic, but I hope it points out new possibilities to those who have never used dsh before.  I have found myself using this pretty extensively with about 50 workstations and publickey authentication and it works wonderfully.  I found it especially useful a year or more ago when I was trying to modify 50+ workstations to conform to a more standard configuration.  I tried several other solutions over a year ago (parallel ssh or something like that) and I didn’t find anything quite as nice as dsh.