Introduction

Pdsh is a tool to allow you to issue commands from a single terminal. We will install this on CentOS 6. Please visit the developers site: pdsh.

Pdsh is a parallel remote shell client. I started using this when there were way to many servers to login into via a Linux Terminal, especially if I wanted to enter a simple command. If you have to check the date on more than a few servers, force a a puppet run on many nodes, start or stop scripts running, then this is the tool for you.

The syntax may take time to get the hang of but it will save you from a lot of headaches. I think this is a SysAdmin’s best friend.


Repositories needed:

# EPEL (Extra Packages for Enterprise Linux):

Install Instructions:

# Lets start by installing the pdsh package from Yum since we now have the EPEL repo configured:

  • yum install push

# Set up user environment by first finding the location of the installed package and creating a profile:

  • which pdsh
  • vim /etc/profile.d/pdsh.sh
  • # For pdsh user environment:
  • export PDSH_RCMD_TYPE=‘ssh’
  • export pdshuser=‘/etc/pdsh/machines’

# What I did here was telling the profile to use ssh and then to export the path to the user I wish to use for pdsh.

# Note, the user here has to have the same username on all the remote machines if you are to do a simple pdsh setup, like whats covered here.

# Add nodes (Directory made need to be made):

  • mkdir /etc/pdsh
  • vim /etc/pdsh/machines
  • Node1
  • Node2
  • Node3
  • ….etc…nodes…

# Here is where we make the root location for pdsh hostname group files. I am going to name mine machine and add

# all the hosts by hostname, you can use IPs, that we will pdsh commands to.

# Password-less user login (pdsh user to user):

  • su – pdshuser
  • mkdir .ssh
  • chmod 700 .ssh
  • cd .ssh/
  • ssh-keygen -t rsa
  • ssh-copy-id -i ~/.ssh/id_rsa.pub Node1

# Here is where we become the pdsh user we made, and add the ssh directory for ssh keys to be stored.

# Once that is done, we generate the RSA SSH Keys and copy them to each node.

# Test that the ssh keys work. There should be no prompt for a password:

  • ssh Node1

# Disable tty for user using pdsh:

  • visudo
  • Defaults requiretty
  • Defaults:pdshuser !requiretty

# By adding these lines, we are only allowing the pdsh user to not need to an interactive shell or terminal session to be sudo

# Please be sure to only allow this for the pdsh user for security issues

Conclusion:

There are many other options we can include, but these I think are a must.

Please post any comments below and feel free to ask questions.