I'm wanting to find computers with ssh open on my subnet but it shows all host that are up in the results and not just the ones that have open ports this is my command
nmap -PN -p 22 --open -oG - 192.168.*.* | awk '{print $2}' > sshopen.txt
Thanks
How To Scan Nmap Ports. To scan Nmap Ports on a remote system, enter the following: sudo nmap 192.168.0.1. Replace the IP address with the IP address of the system you’re testing. This is the basic format for Nmap, and it will return information about the ports on that system.
PORT STATE SERVICE 22/tcp open ssh 80/tcp open http Nmap done: 254 IP addresses (7 hosts up) scanned in 3.78 seconds as the above host is the only one with ALL the ports open. I certainly can post-process the output, but I don't want to rely on the output format of nmap, I'd rather have nmap do it, if there is a way. Show activity on this post.
Nmap commands can be used to scan a single port or a series of ports: Scan port 80 on the target system: Scan ports 1 through 200 on the target system: Scan (Fast) the most common ports:
In order to scan various open ports on our system, we’ll use the command nmap. Before scanning any open ports we need to have nmap installed on our Linux system. Use one of the following options to install nmap on your system first:
You can select with awk to print only in certain cases and not all.
For example, the following matches the last field, if it contains ssh (but you could test also for 22) then it prints the IP.
nmap -PN -p 22 --open -oG - 192.168.*.* | awk '$NF~/ssh/{print $2}' > sshopen.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With