Shell Script: Test SSH Connectivty to a list of boxes

#!/bin/ksh

ERROR=0

for SERVER in `cat server.list`
do
        ssh -n -o Batchmode=yes -o ConnectTimeout=30 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $SERVER "uname -n > /dev/null" > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
                echo "FAILED: $SERVER"
                ERROR=1
        else
                echo "SUCCESS: $SERVER"
        fi
done

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.