선 밖에 선 자유인

SSH login 테스트 본문

IT/System & Network

SSH login 테스트

Hotman 2016. 10. 5. 19:10

여러 대의 서버들에 ssh 로그인 가능한지 확인


-----------------------------------------------------------------

#!/bin/bash


HOSTFILE="host.txt"


stty -echo

read -p "Enter Password : " PASS; echo

stty echo


if [ -f ssh-check.txt ]; then

rm -f ssh-check.txt

fi


touch ssh-check.txt


# SSH 로그인 테스트

for ipaddr in `cat $HOSTFILE`

do

    sshpass -p $PASS ssh -tt -o StrictHostKeyChecking=no <user>@$ipaddr "exit" 2> /dev/null

    CHK=$?


    if [ $CHK -eq 0 ]; then

        echo $ipaddr : SUCCESS >> ssh-check.txt

    else

        echo $ipaddr : FAILED >> ssh-check.txt

    fi

done

-----------------------------------------------------------------

Comments