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

 

posted @ 2020-04-14 14:59  破仔  阅读(275)  评论(0编辑  收藏  举报