Installing distributed shell (DSH) on Solaris, Linux and MacOSX

DSH is distributed shell. It allows you to run shell commands on multiple servers at once and gather the output in the local terminal

Installation

  • Solaris 10 and 11: The dsh package is downloadable for Solaris from the OpenSW website.
    # pkgadd -d http://get.opencsw.org/now
    # /opt/csw/bin/pkgutil -U
    # /opt/csw/bin/pkgutil -y -i dsh
  • Mac
    # brew install dsh
  • Debian/Ubuntu
    % sudo apt-get install dsh

Configuration

Out of the box dsh used default config, but I suggest that you add the following to the config file

General Configuration
  • Global config: /etc/dsh.conf
  • Local config: ~/.dsh/dsh.conf
remoteshell = ssh
showmachinenames = 1
Hostname List

Edit/Create

  • Glocal list: /etc/dsh/machines.list
  • Local list: ~/.dsh/machines.list

Add each hostname or IP address on a seperate line

NOTE: You may need to add SSH key's

alpha
bravo
charlie
192.168.0.54
10.10.0.2

DSH usage

To use dsh, simple pass the actual command yo wish to run. For example:

% dsh -a -c uptime

where -a denotes run for all hosts. You can also pass -c which will create concurrent connections to all servers

Grouping Hosts

You can make a group of servers and run dsh commands on that group of servers only.. To group servers together create a group file under the group directory

  • Global settings: /etc/dsh/group/myservers
  • Local settings: ~/.dsh/group/myservers

Add list of hostnames, one per line.

Example 1:

cat /etc/dsh/group/myservers
alpha
beta
192.168.0.54

Example 2:

cat ~/.dsh/group/myservers
alpha
10.10.0.2
delta

To run against a group, simple use the -g switch and group name. For example:

# dsg -g myservers -c uptime