The mobile development ecosystem is growing rapidly, and developers will need to use a variety of tools and platforms to keep their systems running at peak performance. Linux and Android are cousins and frequently work hand-in-hand with each other. Sometimes it’s helpful to be able to remotely log in from one machine to another. Today, we’ll discuss a couple of programs that let you do just that.
SSH (secure shell) is an effective program for this function and is available on virtually every Linux distribution known to man.
Did you know that the ConnectBot SSH client will run on your Android smart phone and let you log in remotely to your Linux machine? Just punch a valid user name and host IP number into the address bar and hit the Done button. After a second or so, you can enter your password and gain access to the command line. All normal Linux commands will work through ConnectBot, like ls, ps -ax, or df. You can even edit text files with a standard text editor like vi.
If you want to go the other direction, just fire up the SSHDroid server on your smart phone. You’ll find it in the Android market and you don’t even need to have root access for the program to work. I thought it was pretty cool to see commands like ls, ps -ax, and netcfg, all execute properly on my Samsung Captivate. From a Linux terminal I used the standard command line:
rreilly$ ssh firstname.lastname@example.org.
192.168.1.103 was the IP address of my smart phone.
I entered the password and poof, there I was on my Captivate’s command line. I found a list of executable commands in the bin directory. I’ve tried out a couple of simple 3-5 line scripts and they worked as well. It would be great to have some enterprising readers share their experiences with commands like cron and longer, more complicated scripts running on the Android.
A more sophisticated way to log in remotely between your Linux notebook and Android phone is by using VNC servers and viewers. These use the X11 windowing system and are fast and offer high-resolution.
If you want to sit on your Android phone and mouse around your Linux notebook display, set up the x11vnc server. It’s pretty standard in Linux distributions. After installation it can be found in the application menu by the name of X11VNC Server. Once started, you can set a session password and a bunch of other parameters. The server will just sit there and wait for a remote VNC client to connect.
I like the Remotix Lite VNC Viewer on the Android side. It’s found in the Android market. This VNC client gives you full mouse and two-finger zoom control of your desktop. There’s also an on-screen keyboard, that you can display at will. Zoom into a portion of your screen, say, while looking at your browser, and you can tap on links, tabs, and virtual desktops. Everything you do on the big screen (your notebook) appears, in lock step, on your Android smart phone display, and vice-versa. I typed in this line, using the on-screen keyboard, on my Android phone, while in Libre-Office 3.5 on my Linux notebook. Typing is pretty tedious, that way, but you get my point.
I’ve used Droid VNC Server on my Samsung for remote access, from my Linux notebook. This program does require that the phone be rooted. Although rooting is a bit of a pain, I needed the capability so I could show live Android screens during presentations. You simply start Droid VNC server on the phone, then connect to it, from the Linux notebook using something like the Remote Desktop Viewer. Both programs are incredibly simple to set up and use.
Also, don’t forget that the proper ports need to be open for both SSH and VNC to work. Normally, port 22 is used for SSH communications. 5900 and 5901 are generally used for VNC, 0 being the 1st display and 1 being the 2nd display. Make sure your firewall (software or hardware, on your Linux notebook, router, and Android device) don’t block these ports or you’ll chase your tail trying to figure out why nothing will connect.
We’ve examined several examples of remote-access programs to connect your Android to your Linux notebook. I’ll probably be picking up one of the new Tegra 3 tablets, soon. I can’t wait to see how SSH and VNC work on that monster. There is actually a pretty generous variety of SSH and VNC programs out there for both Android and Linux. Both programs are also available for Apple and Microsoft products as well, although I don’t have any experience with those. Give the programs a try and be sure to share your likes/dislikes in the comments or on the Mobile Development discussion boards.