I have several hosts that need to have a one-off RPM installed as well as packages belonging to the CentOS-Debuginfo.repo. These machines currently have the repo disabled and gpgcheck enabled. After everything has been installed, I need rpm --nodeps -e some packages, all the while echo'ing out the hostname of each machine that this has all been done to.

So far, I have this:

# SSH to hosts, then grab the GTS RPM and install it.  Yum install required debugging packages, then rpm to erase unnneeded ones.

cmds="echo $HOSTNAME; cd /tmp && wget http://download.sipxcom.org/pub/epel.bak/6/x86_64/gts-0.7.6-19.20111025.el6.x86_64.rpm /tmp; rpm -i /tmp/gts-0.7.6-19.20111025.el6.x86_64.rpm; yum --enablerepo debug --nogpg install -y db4-debuginfo.x86_64 expat-debuginfo.x86_64 glibc-debuginfo.x86_64 kernel-devel.x86_64 nss-softokn-debuginfo.x86_64 openssl-debuginfo.x86_64 python-debuginfo.x86_64 readline-debuginfo.x86_64 zlib-debuginfo.x86_64; for i in $(cat /tmp/testing/rpms_to_erase.txt); do rpm -e $i; done"

for i in $HOSTLIST
    ssh -qn $i "bash $CMDS" && "rpm -e gdm-plugin-fingerprint.x86_64 gdm-user-switch-applet.x86_64 gnome-applets.x86_64"

As you can see, this is quite ugly. Wondering if anyone may have a more elegant solution.

  • 3
    Ansible, perhaps, or one the many existing SSH multiplexers would be better options. – thrig Mar 3 '17 at 17:43
  • I completely agree. Unfortunately, we're not allowed to install any additional packages/management tools without going through a rigorous process. – loadedmind Mar 3 '17 at 17:59
  • 1
    clusterssh or tmux on your client device (no changes required on the servers). – roaima Mar 3 '17 at 18:11

Clusterssh (command cssh) lets you ssh to multiple hosts at once

cssh server1 server2 server3

and then whatever you type, it appears in all terminals once active.

Not the answer you're looking for? Browse other questions tagged or ask your own question.