Skip to main content

Old phone as SSH server

I guess I'm on a kick trying to actually use my pile of old broken-down smart phones.

This time, while I was at work one day and was wanting to access my home network, I was wishing I had a linux machine at home that I could ssh into. My laptop at home is linux, but I don't leave it turned on. The home server is Windows, because it's also my media center, and sadly, Windows Media Center is still the best option for a media center with DVR. I wanted to run a small, light linux machine alongside it, just to be able to get in via ssh from outside, and do whatever from there.

I had a raspberry pi at one point, which would have been perfect, but I sold it. And for things like this, part of the fun is to do it without buying more stuff. So I decided not to buy another pi. I thought about just running a linux VM on the windows machine, but it's already a bit underpowered for what it does (it gets a little slow when watching an HD recording while also simultaneously recording 2 HD shows).

So I dug around in my pile of old phones, and decided to turn one into a proper ubuntu machine. My first attempt was with a Galaxy S. I installed a fairly straightforward chroot'd linux on it, and it was SLOW. I tried doing an apt-get install of mysql, and I gave up after 15 or 20 minutes of waiting during the installation. That phone went back in the bin.

So I pulled out the LG Optimus G E970. It's more-or-less the same hardware as a Nexus 4, so quite a bit better than the old Galaxy S. Unfortunately, it has a busted screen -- the screen turns on and displays properly, but the touchscreen is completely broken. And I didn't have adb/USB debugging enabled before it broke, which has previously foiled any of my plans to do anything with it. But I decided that this time, that wouldn't stop me.

First, I tried the easy solution, and plugged in a USB OTG adapter, which, if a phone supports it, lets it act as a USB host, so I could hopefully just plug a USB mouse in. Nope, no dice. No OTG support.  I have a bluetooth mouse, but how to get bluetooth turned on, and the mouse paired, without USB debugging enabled?

Well, here's what I finally did (with quite a few other mis-steps along the way that I won't bother documenting):


  1. Since the power and volume keys still worked, I could reboot into recovery mode, and work through those menus. So I wiped the current install, and flashed a current version of SlimRom. SlimRom, as it turns out, has USB debugging enabled out of the box.
  2. To disable the lockscreen from adb, I needed root access, which I didn't have. But I read that if you connect adb while in recovery mode, you have full root. So I rebooted again into recovery, connected adb, and thanks to the tips from this post, pulled the /data/data/com.android.providers.settings/databases/settings.db sqlite database off the phone onto my desktop (using the adb pull command), disabled the lockscreen by running the query update secure set value=1 where name='lockscreen.disabled'; and then pushed the file back onto the device. Once rebooted, the lockscreen was disabled.
  3. Next was the tricky part -- blindly stabbing in the dark with adb shell input commands to try to turn on bluetooth and pair with my bluetooth mouse. It took a bit of trial and error, but the solution for my particular phone ended up being:
#swipe down from top:
./adb shell input swipe 100 0 800 100

#tap top right to flip to the tiles settings screen:
./adb shell input tap 750 10

#hit the settings icon:
./adb shell input tap 720 150

#bluetooth toggle on:
./adb shell input tap 720 250

#tap the bluetooth menu:
./adb shell input tap 520 250

#search for devices
./adb shell input tap 600 40

#select the mouse
./adb shell input tap 200 896

After that, my mouse was working! Then it was pretty easy to attach a bluetooth keyboard, install the chrooted linux (the easiest method is to download the Complete Linux Installer from the play store, although there are plenty of bugs in it. If you are playing along at home, here's the bugs I ran into, and their solutions:


  • Clicking "Start Linux" loads the terminal emulator, but nothing happens OR
  • Clicking "Start Linux" loads the terminal emulator, it does a cd and su, and then nothing happens.
Something is broken with the launcher. You need to run the boot script manually. First su, then do sh /data/data/com.zpwebsites.linuxonandroid/bootscript.sh /sdcard/ubuntu/ubuntu.img (adjusting that last bit to wherever you put the linux image)

  • You can't add users (and various apt-get installs also fail because THEY can't add users)
Something in Android's SELinux implementation is breaking things. In a separate terminal, as root, run setenforce 0, which will disable whatever is preventing it, and probably render your device horribly insecure. Oh well.

Once those things got sorted out, I was able to SSH into the phone, and it works just fine as an ubuntu server. It's a tiny bit slow, but nothing unreasonable. It's currently plugged into the media center to stay charged, and a port forwarded on my router to it, so I can access it from anywhere! 

Mission accomplished: one more half-broken phone from my bin has a use!

Comments

Nathan Tolbert said…
Turns out there was one more problem: I couldn't resolve any DNS lookups as the regular user, only as root.

This page has the fix:
http://archlinuxarm.org/forum/viewtopic.php?f=9&t=4611

Popular posts from this blog

Retrospex 32 Review

RetrospexInternational recently sent me a couple units of their new handheld device, the Retrospex 32, a new dedicated GameboyAdvance emulator handheld.  To make the unit playable out of the box, they pre-loaded a handful of homebrew games, including Anguna, which is why they were kind enough to send me 2 of the units to play with.  I was pretty excited to get my hands on the device and try it (I loved my old GBA micro with a good flash cart!), and see Anguna running on it. So here's my thoughts after playing with it.



Their website lists the Retrospex 32 for £59.99, which is around $100 USD. It seems like it's marketed toward people into retro-gaming (which makes sense for a dedicated GBA emulator device). At that price, with that target market, and such a limited set of functionality (why not make it a multi-machine emulator, and emulate all the old consoles?), it would hopefully do a really good job of it.

The short version of my review: it doesn't. It has one job (emula…

Making the game fun

The real trick for Spacey McRacey (as I'm calling it now) is going to be making it fun.  And that's what I'm rather unsure about at this point.

I have a game design that basically works. The technical issues are mostly sorted out, I just need to get a few more implemented before I can seriously play test it.

But fun? It's hard to know if it's actually going to be any fun to play.  With a 4-player party-style game, it's seems like it might be hard to hit that fine line where everyone is close and competing, where everything feels exciting and tense, as opposed to tedious and boring.  And despite envisioning my game as fun, it might just be boring to play.

Some of that comes down to tweaking it. Tweaking the speeds, difficulties, etc, will make a difference. (If it's too easy to shoot people from behind, then it will be nearly impossible to hold a lead for very long, which could ruin it and make it no fun. If it's too hard to kill the guy in front, it wil…

Killer Queen

So at PRGE, I played an arcade game that just left me amazed.  Killer Queen.

It's a 10-player game. You have 2 cabinets linked together, and 5 players huddled on each one. Each one is a team of 5 people, working together to play a simple one-screen 2d platformer.  But what made it work was the high quality game design.

First, the game is relatively simple, yet there is a lot going on at once.  One player plays the queen, the most important and powerful character on the team. The others start as workers, but can become warriors who can fly around and attack in a very joust-like flappy contest of height.  The real trick is that there are three completely different ways to win: either collect a bunch of berries and bring them back to your base, or ride a REALLY SLOW snail across the screen (while other people try to kill you, and you hope your team protects you), or kill the enemy queen 3 times.  There's some other things going on as well (using berries to upgrade, capturing upgr…