Tuesday , 16 July 2019
Breaking News

Automation using PSSH/PSCP/SSHPass


By default, pssh uses at most 32 ssh processes in parallel to ssh to the multiple servers. (This is important in case you’re controlling hundreds of servers.)

By default, it also uses a timeout of one minute to ssh to a node and obtain a result. For ssh commands that take longer than this (e.g., sleep 61), the -t option can be used.

Note that pssh have a default timeout of one minute. pscp and prsync have no default timeout, but one can be specified using the -t option.

Environment Variables:-

 # export PSSH_HOSTS="/root/hosts.txt"
 # export PSSH_USER="<uname>"
 # export PSSH_PAR="32"
 # export PSSH_OUTDIR="/tmp/outdir"
 # export PSSH_VERBOSE="0"
 # export PSSH_OPTIONS="UserKnownHostsFile /tmp/known_hosts"

Runing pssh using root:-

syntax - 
  $pssh -o outdir -h hosts.txt -l root -A -i '<commands>'

  $pssh -o outdir -h hosts.txt -l root -A -i 'yum update vsftp'

  $pssh -o outdir -h hosts.txt -l root -A -i 'rpm -qa | grep -i vsftpd'

Running pssh using sudo:

  #pssh -o outdir -h hosts.txt -l <uname> -A -i -x "-tt" "sudo /usr/bin/yum -y update vxftpd"

Running local script on sevaral servers using PSSH:-

  #pssh -o outdir -h hosts.txt -l root -A -i -I < shellshock-test.sh


  #pscp -h hosts.txt -l <uname> /etc/hosts /tmp/hosts
  Using the -r option will perform a recursive copy for copying entire directories.


Adding ILO user in multiple servers using SSHPASS

copy add_user.xml to all hosts

  #for i in `cat hosts.txt`;do sshpass -p '<userpasswd>' scp add_user.xml uname@$i:/tmp; done

Once the file copied run below command

  #pssh -o outdir -h hosts.txt -l root -A -i 'hponcfg -f /tmp/add_user.xml'

Check Also

Elit eget tincidunt condimentum

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor …

Leave a Reply