ssh连接测试.sh
#!/bin/bash User=$1 filename=$2 function getConnection() { timeout 2 shh -o NumberOfPasswordPrompts=0 $1@$2 "pwd" &>/dev/null if [ $? != 0 ];then echo -e "\n无法连接到 $1" continue else echo -e "\n成功连接到 $1" fi } #getConnection $User $filename for line in `cat $host` do getConnection $User $line done