Android and Linux

Sunday, March 13, 2011

ssh hiccupped

I will never understand some things.

Last night, I sat down to watch a movie and dimmed the lights using ssh on my phone (using a Zoom widget to run the ssh command to my PC and trigger heyu controlling home automation, it's all here on the blog somewhere). After the movie, I went to brighten the lights and found that it didn't work. After much investigation, I found that ssh was failing to connect to my PC. No matter what I tried, ssh failed with this error:

no address associated with hostname

I recently installed an app which created network sockets in order to watch network traffic, so I thought maybe that screwed something up. I had no idea how to fix it, and it was time for an update anyway, so I wiped the phone and installed the latest Cyanogenmod today (7RC2). After getting everything installed and set up, I dropped to a terminal and tried to ssh in to the PC and got:

no address associated with hostname

What the..? Ping and everything else worked, so it didn't seem to be a DNS issue. Maybe Google shipped out an Android OTA update that changed the network stack somehow?

I finally found a fix by adding my PC's IP address to /etc/hosts and giving it a name:

xx.xxx.xx.xx home

Then ssh user@home worked! I keep the home IP address stored in a file so it was easy to change all of my ssh commands by changing the ip address in that file to "home", and it's worked all day with no problems.

Later tonight, I was trying to set up a new connection and accidentally typed ssh user@xx.xxx.xx.xx and, after changing absolutely nothing, it works again!

Well, the two lessons for today are that if ssh gives you that error, try hardcoding the ip address in /etc/hosts and connecting to it's hostname instead of the ip directly and when it comes to computing, just accept the fact that sometimes, things will make absolutely no sense whatsoever.

Followers