-
Notifications
You must be signed in to change notification settings - Fork 27
/
sshanalog
executable file
·33 lines (29 loc) · 717 Bytes
/
sshanalog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
valid_ip()
{
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
echo $stat
}
command sshpass >/dev/null 2>&1
if [ "$?" -ne "0" ] ; then
echo sorry, your distribution needs to have 'sshpass' installed
echo try \'sudo apt-get install sshpass\' OR \'sudo yum install sshpass\'
exit
fi
if [ $(valid_ip ${1}) -eq "1" ] ; then
echo "$0 : invalid IP number, CTRL-C to break DNS lookup"
fi
sshpass -panalog \
ssh -oStrictHostKeyChecking=no \
-oUserKnownHostsFile=/dev/null \
-oCheckHostIP=no root@${1}