Introduction
This document provides steps to configure Distributed Shell on AIX to enable operators to send commands to multiple servers at the same time.
Requirements before proceeding
- SSH key exchange between the source host that will be issuing the dsh command and the destination hosts that dsh would manage must be established (see \\sysdev-dms-2\sysadmin\HOW-TO\AIX OS\SSL key exchange\sg246606_openssh.pdf).
- The source host that will be issuing the dsh command must have dsh package installed. When issuing the following command, the csm.dsh package should be displayed.
Ø lslpp –L | grep dsh
csm.dsh 1.7.0.10 C F Cluster Systems Management Dsh
- Optional: A file that contains the list of hosts available. In the IM environment, the following file on imcsm is used. This file is currently maintained by Cheuk Man, Tong, which contains the complete list of hosts available in IM. You are free to use your own host list if desired.
Imcsm:/homecomm/cmanton/scripts/khuang/hostinfo.txt
- This document assumes that ksh is used.
Order of Operations and Commands
DSH requires the following environment variable in the shell.
DSH_NODE_RSH: This variable indicates which remote command executable to use when dsh is called. In this case we will use SSH.
DSH_NODE_LIST: This variable point to a file that contains a list of all hosts that one would want to execute a command on.
DSH_NODE_OPTS: This variable is optional. It speechifies which options are passed to the remote command. When set to –q, it will execute ssh –q on the remote host, which will suppress the banner messages.
- Log on to the host that will be issuing dsh commands, which in this case should be imcsm.
- Open the user profile file; in this case it should be either .profile or .kshrc.
- Add the following lines to .profile or .kshrc file; you could change the DSH_NODE_LIST by providing your own path to the host list.
DSH_NODE_RSH=/usr/bin/ssh
DSH_NODE_LIST=/homecomm/cmanton/scripts/khuang/hostinfo.txt
DSH_NODE_OPTS=”-q”
- Once the profile is saved, log out and log back into the host.
Usage
Scenario #1
To find out if a user account gliu06 exists on the hosts wimcsm, impvcs01 and irdqa05, simply enter the following.
Ø dsh –wwimcsm,impvcs01,irdqa05 ‘lsuser gliu06’
The –w option allows a user to supply the host name in command line separated by comma. Please be advised that there are no space between –w and the first host name.
Scenario #2
When executing dsh without any options, it will pick up the host list from the DSH_NODE_LIST variable.
Ø dsh ‘lsuser grproy’
Above command will go through all hosts defined in the DSH_NODE_LIST variable, which could create a large output of user does not exist message.
Refine the command to redirect errors to /dev/null to generate a more readable output.
1 = stdout, 2=stderr; hence redirecting standard errors to /dev/null.
Ø Dsh ‘lsuser grproy’ 2>/dev/null
Or better yet. Piping the output to cut command. –d “:” means uses colon as delimiter and –f1 outputs the first column.
Ø dsh ‘lsuser grproy’ 2>/dev/null | cut –d “:” -f1