Dennis Kaarsemaker

Adventures in lazyness

Last update on Feb. 27, 2013.

My laptop is sitting a few meters away from me. I'm behind a desktop in the same /24. I'd like to SSH to this laptop, but don't know its IP address. On this network there are quite a few machines, mostly macs. How do I find the IP address?

Arp and nc to the rescue! First we arp-scan the network, then we find SSH versions.

$for h in $(arp-scan --localnet | grep 10.15 | cut -f1); do echo -ne "$h\t"; (echo "" | nc -w1 $h 22 || echo)|head -n1; done | grep ubuntu    SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1    SSH-2.0-OpenSSH_6.0p1 Debian-3ubuntu1    SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1    SSH-2.0-OpenSSH_6.0p1 Debian-3ubuntu1

Of course it was the last one I needed :)

Next entry

Previous entry


  1. ilmari

    ilmari on 02/27/2013 4:07 p.m. #

    Or you could install avahi-daemon on the laptop and just address it as <hostname>.local.

  2. Oli Warner

    Oli Warner on 02/27/2013 4:19 p.m. #

    I'd favour `arp -a` (because it doesn't require extra packages or root) or something like `nmap -p 22 --open -sV` because arp won't always detect all devices.

  3. Dennis Kaarsemaker

    Dennis Kaarsemaker on 02/27/2013 7:42 p.m. #

    Ilmari, installing that requires access. Catch-22 :)

Post your comment


February 2013
November 2012 March 2013