So I’m working on regisgtering 100+ RHEL systems to a new RHN Satellite server.  The following command line for loop magic mad this a snap, thought it was worth publishing.

First, I’m using a passworded SSH key.  So you’ll want to use ssh-add (with ssh-agent) to store your credentials, otherwise it’ll be a pain to re-type your password with every connection. I’ve also stored my sudo password (which is the same on all of the servers i’m accessing at the moment) in a file, called pwd.txt.  Finally I made a list of servers in a file called servers.txt.

Once you’ve done that, it’s as simple as this:

for i in `cat servers.txt`; do \

  ssh -t $i ” echo `cat pwd.txt` | sudo -S sh -c ‘wget –no-check-certificate'”;\

  ssh -t $i “echo `cat pwd.txt` | sudo -S sh -c ‘/bin/bash'” ;


This worked wonderfully!