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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s