Tuesday, January 3, 2012

Developing on a Chromebook - Part 3: X-Forwarding, or "Eclipse on a Chromebook"

As I've mentioned in previous posts on this blog, developing on a Chromebook (read, in the cloud) is possible. It's partially imperfect and unstable, but it's possible. But, (unfortunately?), for some of us, there's more than just JavaScript. If you're an Android developer, there's a good chance you need an IDE like Eclipse.

The good news is: it's possible to use Eclipse "on" a Chromebook. The bad news: you need another device. Fortunately, you don't need another laptop which suits your needs and is able to compete with your Chromebook (weight, size, battery). Instead, you need some kind of server. For me, it's my old (read, 5 years or so) computer. You see, hardware doesn't matter too much. You could use an old laptop too. All it needs is a working network connection and enough power to run Eclipse. To justify the expense of a new device, you could use this server for other things, like streaming media, network storage, printing, etc too.

The method I'm talking about is called X-Forwarding / X11-Forwarding. I'm not going into much detail about what it is and how it works, but to cut it short: it forwards an application's GUI over the network from a server to a client (in this case, your Chromebook). That means you only have to install the application on your server, but you are still able to see and control it on your client.

Let's jump into configuration. I'm running Ubuntu Server 11.10. Assuming a plain install, you need to do the following steps:
  1. configure server
    1. sudo apt-get install xauth
    2. set "X11Forwarding yes" in your /etc/ssh/sshd_config 
    3. restart ssh using sudo service ssh restart
    4. set "ForwardX11 yes" in your /etc/ssh/ssh_config
    5. (some applications (read, most written in Java) need "ForwardX11Trusted yes" set in /etc/ssh/ssh_config too)
  2. initiate SSH session from Chromebook
    1. ssh -Y username@server
    2. (sudo apt-get install eclipse-jdt)
    3. eclipse

Important note: usually you would activate X-Forwarding on the client using ssh -X username@server, but for me, it didn't work that way. I guess it's due to Chrome OS and some restrictions. However, be aware that using the -Y parameter might be more insecure than setting everything up the proper way and using -X instead, as someone pointed out in this discussion.

Obviously, there are some disadvantages too. For example, there's no window manager for X11 available in Chrome OS, so every window is being displayed in fullscreen. Without any controls. I hear your laughter, thinking "Ha, no problem! There's Alt+F4!"... Look at your keyboard and think again. There's no F4 on a Chromebook's keyboard. :) You have to hope for every application to display a close button for you. If it doesn't you're still able to switch back to your SSH session and kill the application the hard way (Ctrl+C or killall applicationName).
Another annoying aspect you might face is performance. If your network connection is slow, you might try starting your SSH session using ssh -YC username@server, which compresses all traffic for you. But keep in mind that this could slow down your Chromebook's slow hardware.

And now that you have a server set up, I recommend you to read this article, called "Tips for Remote Unix Work (SSH, screen, and VNC)". Moreover, shellinabox is worth a look. You wouldn't even need to switch your Chromebook into developer mode in order to access your server via SSH. However, you can't use shellinabox for X-Forwarding or most of the tips shown in the previously mentioned article.

Now, go and look for some old hardware you can set up your server on! ;) And don't forget to ask questions in the comments or on Google+...

Want to read more about this topic? Check out the other posts of this series:
Part 1: Chromebook
Part 2: Cloud
Part 4: Ubuntu

1 comment:

  1. In fact this is a very good approach Thomas, thanks for sharing