I have a simple for loop one liner I use to check for things across a number of servers that have the same password set. I want to develop this one liner into a script that logs into a cluster of servers via IP address, prompts for a password and performs a command. Such as restarting a service. This is what I use:
for i in {1..253}
do sshpass -p PASSWORDHERE ssh -o StrictHostKeyChecking=no [email protected].${i} 'hostname
echo "Checking if foo.log exists: `ls -lh /var/log/foo.log | wc -l`"
echo "Checking if bar.log is present: `ls -lh /var/log/bar.log | wc -l`"
' 2>/dev/null; echo ""; done
My script-fu is weak and I really don't have much of a clue where to start. Incidentally I want to achieve this with a basic set of tools. I'm not able to install anything third party.
Any help appreciated.