March 21, 2015

How to Set Up Your Linux Dev Station to Work From Anywhere

asus transformer tabletBack in 2008, I was vacationing with my family, and as I sat on the beach, like any good techie, my mind kept going back to some code I had been working on earlier that day while sitting in my cabin. My wife insisted I leave the laptop at the cabin, and, having only my phone in hand, I imagined there must be a way to get connected to my work. The phone had Internet and a browser, and there was a faint data connection. But there really wasn't any way I could work. So instead I had to put the phone down and enjoyed some time offline.

Fast forward almost seven years, and times have changed. Now I take my tablet with me wherever I go. And with that tablet I can continue doing my work--not just tablet work, but all my work. Today, using my tablet, I was coding in node.js and later in C++ using the Geany IDE running on an Ubuntu 14.04 machine. And this very document I'm typing is made possible with LibreOffice on that same Ubuntu machine. My code files are saved away in a git repository on another machine, and my other documents are stashed in a Dropbox folder that gets synced to all my machines. And yes, dare I admit, about once every couple of months I need to boot up a Windows machine and do something on it.

All of this is happening through an Android tablet. Or two actually -- a Nexus 7 tablet, and an 11-inch Asus Transformer with a keyboard attached. (I do have a regular computer, which I also use for said work.) I carry my tablets in a little pouch not much bigger than the 11-inch tablet and I can get my work done wherever I go. This afternoon I'll be back on my main computer working. Then tonight I'll be sitting at my son's karate class working away on that same work.

What I want to do is show you the configuration I came up with for a new mobile lifestyle. I can work from nearly anywhere, provided there's a data signal. And I have enough backup battery power to last me about 30 or so hours. When putting together this configuration, I had several goals in mind:

  • (1) Don't rely on a single device or computer to work from, and to be able to work both from my computer at home or any of my tablets or even to be able to borrow somebody else's computer if absolutely necessary. If I lose my tablet, I want to be able to buy a new one and pick right up where I left off.
  • (2) Don't rely on a single server. Servers and hosts can go down and I don't want to be left stuck.
  • (3) Be as mobile as possible and able to work from anywhere I want, as long as I have a data signal and eventually a power outlet to plug into to recharge.
  • (4) Be able to create, save, and edit my writing files (such as this one I'm typing) without having to copy files around manually.
  • (5) And finally, to hopefully be able to use native apps on the tablets.

These were my goals, but I didn't reach them all. The native apps thing didn't go so well. Also, working on a friend's computer requires the use of a key file, and I'm not particularly comfortable with putting key files on other people's computer, nor am I comfortable typing passwords into other people's computers in case they have key logging software. (I know somebody who keeps such software on his computer to discover passwords wgen friends borrow his computer.)

First I'll give you the short version of the configuration I settled on. Then I'm going to talk about several different options I tried out and why they weren't suitable in my case. But your needs will likely be very different from mine, and some of those other options might work well for you. Also, my final setup isn't perfect by any means, and as such I welcome discussion in the comments about how this might be improved for the benefit of all of us.

Mobile Life: The Short Version

The super-short version of this story is I run VNC software on my Linux servers, and I remote in using VNC.

Now here's how I handle my files.

I ultimately settled on using Dropbox for my non-critical files. These are files where it would not be a serious problem if my Dropbox account gets compromised. Usually this is for my writing work. If somebody broke in, they would find an early draft of this article, for example. Not a huge deal.

For files that require somewhat more security (but still not huge security), I'm using a version control system. Specifically I have a git repository on a hosted Linux server. These are files that I would prefer people not get their hands on, but if they do, it's not the end of the world.

For files that are important (contracts, banking information, and so on), I keep private and are not available in my "mobile life" setting. It's too risky. If I'm out of town on business and somebody at a bank needs a copy of some mortgage papers, I'll call my wife and have her retrieve it, or they'll wait until I get home. I'm not storing that "in the cloud."

Now for the hardware.

I still have my main computer, a quad core machine at home that I work from. It's actually a laptop, but it's plugged into two monitors, an external keyboard and mouse, and I generally treat it as as regular workstation computer. I used to cart it with me everywhere (minus the monitors and keyboard), but it's not the lightest laptop around, and if it were to get stolen, I would have a huge problem on my hands with all that data on it.

I also have a Nexus 7 2013, which runs Android (and I just upgraded to Android 5.) I originally tried using an external keyboard, but the tablet was just too small to stare at for long hours. So I bought a second, bigger, tablet.

The second tablet is an Asus Transfomer TF701T. This is a 10-inch tablet, and I have the keyboard Asus makes specifically for it. I also have a bluetooth mouse, although I can't always use that if I'm just sitting in a chair and not at a table. (But the keyboard has a small trackpad which works fine.)

And now the servers. I'll get to the software shortly.

I have a few hosted Linux servers. I personally like DigitalOcean because they're not very expensive. I have multiple servers running (not just for my personal "mobile" work but my professional work) for under $100 per month. Amazon has come down in price with some of their servers lately, too. One nice thing about Amazon is you can turn off a server and pay only pennies per month to keep it there. DigitalOcean charges you per server whether it's running or not. But with prices at like $10 per month, that's not a huge problem for me.

juice sshOne of my goals is to not be reliant on a single server. Ideally, if DigitalOcean were to shut down right now, I could be up and running elsewhere in a matter of minutes--at least ideally, anyway. Realiatically it would probably take me a day or so to get back up and running. Presently I have everything backed up onto Amazon's S3, which I'm finding is ideal for storing large files. I don't have images of my drives backed up, as those aren't portable between hosts. Instead, I keep a full backup of my github files. I'll get to that when I go into more detail about the software configuration.

But first, here's the short version of the software.

I already mentioned github and Dropbox. I went through several different cloud storage services before ending up with Dropbox. Previously, Ubuntu One was perfect for me, but it shut down. I tried a few others and then realized Dropbox works great for what I'm doing. It synchronizes my files between my machines without me having to do any work. And if I have two servers running on two different hosts, and I save a file to a folder under ~/Dropbox on my main computer, within seconds that file is saved on my running hosts. If I'm away from home and go into one of my servers and save to ~/Dropbox, that file is saved back to my home laptop. Changes and deletes are similarly propagated. And so far, I've never had any trouble.

But what about editing my files? This took a while to get going. Again, the short answer is I use VNC to log into my servers, where I run LibreOffice. But with the keyboard and mouse, my larger tablet basically turns into a small netbook, and I'm able to work. The VNC client I went with is called Remotix. There are versions for both Android and iOS, and it can easily connect to both a Linux VNC server and a Windows RDP server. It reads the mouse and trackpad just fine. When I'm on my smaller tablet without the keyboard and mouse, I can move the mouse pointer around by dragging my finger on the tablet screen just like I would on a trackpad. I'll have more to say about this and why it was important to me when I talk about the VNC apps in detail in a future article and how I chose the one I did.

I don't only use VNC, though. There are some nice terminal programs for Android that support ssh. The one I went with is called JuiceSSH, but there are a few good ones available.

More issues to address

So that's the short version. Yes, it amounts mostly to VNC, but I'm able to go mobile. There are some issues that aren't perfect, and I'll talk about all that in detail as well. For example, my ssh key files are sitting on my tablets, which I'm not fond of. But they require a passphrase. And the tablets have a very long PIN to unlock them, and no important files are stored on the tablets. If a tablet ever gets stolen, I'll generate a new key, log into my server, and replace the existing key in the .ssh directory with the new one, likely long before anyone cracks both the PIN and the ssh key file passphrase

In the next couple of articles, I'm going to talk about different software options that I tried, and how I came to arrive at the configuration I ended up with. (For example, I wanted to use a native word processor app on the tablet, but I hit some snags there. I do, however, occasionally use a native code editor called DroidEdit, which I'm able to read and write remote files via ssh.) 

droidedit screenshot

But some of these software options that I decided against might still be great for you. And then I'll wrap it up with a discussion of exactly how I configured my Linux servers. I learned a lot about configuring SSH on my server, and setting up a simple but nice desktop environment on my servers (I went with LXDE but tried many different ones), and I'll share those details with you as well, including my attemps at tiling window managers through a tablet. And I welcome any of your thoughts on how this process might be improved so we can all make our lives easier and more mobile. Stay tuned!

p.s. Midway through this draft I returned home and finished writing it on my main computer in my home office. Now that it's finished, I will retire to the couch for the evening, but I'll have my Nexus 7 in hand so I can give the article another read-through before submitting it to my editor... all without copying any files around and without having to disconnect my laptop. Call me lazy, but life is good in this new mobile era of technology.

Read part 2: Choosing Software to Work Remotely from Your Linux Dev Station

Click Here!