Connecting to your Linux system from a smartphone
Keep In Touch
Tune in to your Linux laptop anytime from an iPhone or iPod Touch – or adapt this technique to reach your system from other mobile devices.
Like many, I have a laptop. Also like many, I have a girlfriend who wants to use my laptop, so I created an account for her in Ubuntu Jaunty; she can use the "switch user" session feature in the upper-right corner whenever she wants to log in. Now she has her desktop, and I have mine. However, sometimes I need to use the system at the same time she is logged on.
When she is using the system, I turn to my iPod Touch for computing tasks. The Touch starts faster than a conventional PC. I can check my mail, browse the web, and even play a game or two to make the time pass while she rearranges her MP3 collection. But some problems still require a full computer system. For instance, I have an account on a torrent site, and that connection must go day and night or I'll lose the account. Also, I need to convert the downloaded movies from XviD to MP4 with HandBrake, a CPU-hungry application that requires real PC hardware.
The ideal solution is to work from my iPod when I can, then connect to the laptop when necessary through a remote session using the iPod as a remote VNC client. To make this system work, I need to connect to a VNC server running in the background on the laptop – without the need for a separate SSH session to start the server manually. Also, it is important for this VNC connection to be invisible to the user logged on to the laptop – I want my own desktop, not a view of the current desktop session – and the connection must continue unhindered, even if my girlfriend switches the local desktop to her own account.
In this article, I describe a technique for remote connection to a Linux laptop or desktop system from an iPod Touch. The instructions for an iPhone are similar, and some variation of technique will work for almost any handheld system that has a VNC client and is capable of participating in a local wireless network.
Setting Up the Client
The first task is to install a VNC client on an iPod Touch, iPhone, or similar device. I use Jaadu VNC [1], which I have found to be one of the best VNC apps for Apple devices. At US$ 24.99, Jaadu is pricier than other similar VNC options, but it also offers some unique options that are specifically tailored to the iPhone's small screen, such as special buttons to mimic a Ctrl+Alt+Delete command, saved servers, support for high resolution, and customer support. Setup is fairly easy: Just install Jaadu VNC through the Apple Store; input your VNC server's IP address, username, and password (Figure 1); and the rest is done by the application, which automatically connects and offers to bookmark your servers. If you want to use Jaadu VNC as a view-only solution, you can even turn off the virtual mouse and keyboard. If you don't like Jaadu VNC, you can use one of the alternative VNC clients available for the iPhone, such as RealVNC, Vnsea, or Mocha VNC Lite.
Performance Matters
The higher you set the refresh rate of the VNC server and client, the more CPU your PC will use. This same principle also applies to the number of colors you want to view: The more colors you chose to use for a perfect image on the viewing end, the more your CPU readings will increase. VNC technology works by sending sequences of screenshots. Practically each time a connection is established with x11vnc, your PC will start taking screenshots and sending them through the network in an attempt to form a flowing screencast of the respective images.
This will also consume some of the bandwidth. If you plan to use Jaadu VNC, note that you can change the refresh rate and number of colors to be displayed directly from the application. If the application you plan to use does not have such settings, you can specify them on the server end. For the refresh rate, use -xrefresh yy, where yy is the rate in seconds. To stabilize colors, use the -8to24 or -24to32 arguments for better performance. If these options still don't satisfy your needs for a perfect balance of quality and quantity, consider using the nice command in combination with x11vnc to run the VNC server with a modified scheduling priority – for example: nice -n 20 x11vnc -many -rfbauth /home/user/.vnc/passwd -find.
The Server Side
The next step is to configure a VNC server on your Linux PC. The goal is to set up a VNC server that will run in the background and let the remote user create a separate session that is independent of the current desktop user. For this article, I will use the x11vnc VNC server, which is available from the project website [2]. Also, you will find x11vnc in the repositories of many popular Linux distros. Most VNC servers launch a separate X Server session at startup; however, x11vnc has the ability to connect to an existing X Server session. This feature means you won't need to consume memory launching a new session. It also means all your open applications will be available right away to the VNC client: You can continue without the need to save and re-open your work.
If you are working on a Debian-based system, you can install x11vnc on your laptop or PC:
sudo apt-get install x11vnc
The goal is to make x11vnc start automatically at boot so you won't have to SSH from the iPod Touch to the laptop and manually start the server. To make x11vnc autostart, place it in an rc.local file. Or, you can use the native tools of the Linux desktop to configure x11vnc to start with the system. In Ubuntu, for instance, choose System | Preferences | Startup Applications and click the Add button to enter a command for starting xllvnc (Figure 2). Place the x11vnc startup string in the box labeled Command. When you start the system, first the X server will start, then Gnome will start, then x11vnc will launch to display a fresh new X server (Figure 3).
Security First
If you're paranoid, or if, by any chance, your wireless router is not as secure as you wish it would be, you'd better set a password to connect to x11vnc. This password will also come in handy if you're not connecting through the local network but are attempting to access the server through the open Internet. (A remote connection from beyond the LAN will, of course, require additional considerations regarding firewalls, open ports, and other perimeter security issues.)
To set a password for x11vnc, use vncpasswd, which is found in the tightvncserver package residing in Ubuntu's default repositories. The vncpasswd command will prompt you twice for a password, which will be stored and encrypted in ~/.vnc/passwd.
X11vnc must keep running even after the client VNC application logs out. By simply launching x11vnc with no arguments, the VNC server will shut down immediately after you close the client. Use the -many or -forever argument to keep the server listening for connections.
Because I don't want other people peeking at my desktop through the wireless network with other VNC clients, I'll use the -rfbauth option so that x11vnc will prompt for the password each time I log in.
By now, the command looks something like:
x11vnc -many -rfbauth /home/user/.vnc/passwd
To make sure x11vnc won't use the local user's home path, you must specify the full system pathname to the password file.
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4
-
Fedora Unleashes Atomic Desktops
Fedora has combined its solid distribution with rpm-ostree system to make it possible to deliver a new family of Fedora spins, called Fedora Atomic Desktops.
-
Bootloader Vulnerability Affects Nearly All Linux Distributions
The developers of shim have released a version to fix numerous security flaws, including one that could enable remote control execution of malicious code under certain circumstances.