ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#!/bin/bash
HOST="$1"
LISTDIR="$HOME/hostlists"
LIST="$LISTDIR/$HOST"
if ! [ -f "$LIST" ]
then
/usr/local/bin/nmap -P0 -sT -p22 $HOST 2>&1 | egrep 'closed|filtered|Failed to resolve' > /dev/null
if [ $? == 0 ]
then
echo "$HOST - WARNING NO SSH"
else
echo "$HOST - OK"
fi
exit
fi
for go in `cat $LIST`
do
/usr/local/bin/nmap -P0 -sT -p22 $go 2>&1 | egrep 'closed|filtered|Failed to resolve' > /dev/null
if [ $? == 0 ]
then
echo "$go - WARNING NO SSH"
else
echo "$go - OK"
fi
done
I have a set of host lists at $HOME/hostlists (like lists of all the Solaris 10 hosts, all the production hosts, all the Sparc hosts etc). The above script takes a single argument, which can be either the filename of one of those lists, or a single hostname. Just change the '-p22' arg to '-p23' to test telnet.
#!/bin/bash
LIST="$1"
if ! [ -f "$LIST" ]
then
exit 1
fi
for go in `cat $LIST`
do
/usr/local/bin/nmap -P0 -sT -p23 $go 2>&1 | egrep 'closed|filtered|Failed to resolve' > /dev/null
if [ $? == 0 ]
then
echo "$go - No telnet"
else
echo "$go - Telnet on"
fi
done
Run that with the list of hostnames as the argument, and it'll spit out the telnet status of the hosts.
After working with several senior nix admins and even working with nmap, we still recieve false/positives when scanning the Cisco NAM version 1 and 2 when scanning only the telnet port 23. It seems at though they are enabled but are set not to recieve any logins. I have not looked at the devices configuration but when you telnet to them, it says connected and then in disconnect you. This is on several devices. This only happens with the Cisco products. Can anyone tell me what could be the issue and if there is a solution for this problem?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.