Created
July 12, 2011 09:33
-
-
Save bkenny/1077680 to your computer and use it in GitHub Desktop.
SSH Key Port Scanning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
# Script to check if port 22 (SSH) is open within the range, secondly if our SSH key is accepted by that server. | |
# Insert your SSH Key here | |
KEYPUB="/link/root/.ssh/file"; | |
RANGES="0.0.0.0/0 1.1.1.1/1" | |
for i in `nmap -sT -n -p 22 -P0 -oG - $RANGES | grep open | awk '{print $2}'` | |
do | |
ssh -i $KEYPUB -q -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@$i exit 2>&1 >/dev/null | |
if [ "$?" = "0" ]; then | |
# echo the IP of the server into the document. | |
echo $i >> log-file-of-servers-allowing-connection.txt | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment