Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am often on one computer in my house and I would like to SSH to another one, but often don't know the IP address of the one I want to connect to. Is there a way, from the command line, to scan the local network so I can find the computer I want to connect to?

share|improve this question
If you don't know which computers are connected to your house's network, I think you might have a problem... – Massimo Apr 5 '12 at 8:31
...and how do you know you're sshing into the right one? Time to sort out your ip addresses / name lookups. – symcbean Apr 5 '12 at 9:00
In defense of Andrew: yes, it's desirable to set unchanging IPs in the DHCP lease, and to have local names. However, consider the real-world case where I just carried a headless Ubuntu PC into the office and hooked it up. For the first connection, I wanted to find the IP without carrying a keyboard and monitor over to it. To symcbean's question, it was easy to know the correct PC based on the MAC address decoding (automatically done by nmap/Zenmap) to the motherboard manufacturer, and the operating system used. Sometimes you don't know the IP and need to find it. – Phrogz Nov 12 at 18:27

3 Answers 3

up vote 6 down vote accepted

Use "nmap" - this will tell you which hosts are up on a network, and indeed which have port 22 open. You could combine it with a few other tools (like grep) to produce more targetted output if need be.

Note: do this only on YOUR network. Running up nmap or its equivalents on someone else's network is considered bad form.

share|improve this answer Use BluePortScan if you want a more simple thing than nmap – Gk. Apr 5 '12 at 7:16

From the command line you could:

sudo nmap -sS p22

Substitute for the local address space on your network. I sometimes use this when I plug in a headless rasberry pi and want to find where to ssh to.

share|improve this answer
Exactly one of the use-cases that lead me to ask this question. Thanks! – Andrew Nov 14 at 20:27

but often don't know the IP address of the one I want to connect to

Isn't this what DNS was invented for?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.