The ConnectTimeout option specifies that if it cant make a connection in the specified time, than it stops trying, and moves on to the next iteration. Otherwise you can wait the default of 45 seconds.
for i in $(cat servers.txt); do if ssh -o ConnectTimeout=10 $i; then echo "$i is the one that works" fi done
My suggestion is to have servers.txt file actually be the host entries in ~/.ssh/config :
Otherwise, just type out:
Post a Comment