To spend the long weekend last week, I’ve got something to play with — trying to login to my RPi B from my phone (Android 4.4.4 – KitKat). Both of my devices are wi-fi connected to a router. I am certain there will be numerous ways to achieve the goal and probably more convenient with graphical interfaces, but this command line approach was what I did, and it worked well.
First, I installed ConnectBot on my Android phone. It is an Android SSH client similar to PuTTY in Windows, which allows you to login to Unix machine (in this case, it is the Raspberry Pi). After that I installed Hacker’s Keyboard on my phone. This application let you type in special keys like CTRL, ALT, SHIFT, Fn, etc, which are unavailable on the default Android keyboard layout. With this two apps installed, I needed one more thing, i.e. the IP address of my RPi.
IP address was given dynamically by the router. How could I find out the IP address of RPi? On the other hand, DNS server nor hostname file was not used, so I could not connect to my RPi by hostname. A solution that I could think of was something to do with MAC address and IP address binding. I already knew the MAC addresss of my RPi beforehand, i.e. 64:66:b3:0b:a0:91. So, I needed to find out what IP address was paired with the MAC address.
MAC and IP address pairing table can be found and listed by command cat /proc/net/arp. However, this table may not always give all the connected hosts in the network if the local machine (my Android phone) never tried to communicate with them. Indeed, my RPi was not listed in the Android ARP table. To solve the issue, I used nmap command. You can get nmap-4.01 for Android here.
Then, I started command line interface on the Android by opening the ConnectBot app, add new host, and choose local, which will appear by tapping at the laptop icon (see picture below).
Then, go to the directory where nmap was located. Issue the command ./nmap -n -sP 192.168.61.0/24, which scanned the entire addresses in the local network. After that, use the command cat /proc/net/arp | grep 64:66 . This time my RPi MAC address was listed in the ARP table. However there was something so surprising. The RPi MAC address was paired with two IP addresses. Something that I never knew possible.
And yes I was able to login to both IP addresses 🙂