VirtualBox has gained a following as an alternative to VMware. Although the binaries are proprietary, they’re free for non-commercial use. VirtualBox has some compelling features for desktop users:
- Automated installer that runs under Windows, Linux, and OSX. For Linux users, there are official versions for Ubuntu, Debian, openSUSE, Fedora, Red Hat Enterprise. A 64-bit CPU with hardware virtualization support helps, but isn’t required.
- User interface that’s easy to grasp. The documentation is well-organized. If you get stuck, there’s a large community forum.
- Desktop integration with video and mouse. VirtualBox runs your virtual machine in a seamless window, just like normal applications. By installing Guest Additions, you can run your VM in high resolution with video acceleration.
- File exchange. VirtualBox’s Shared Folders let your VM read and write files on your local drive. Of course, you can also use networking to access file shares outside the VM’s virtual drive.
Remote Connections #
There’s one VirtualBox feature, however, that makes it stand out for me: you can access a VM from another computer – not just the host machine – using any client software compatible with Micosoft’s Remote Desktop Protocol (RDP). When you run the Remote Desktop Connection software in Windows (from the Start | Accessories menu), you’re using RDP.
What’s so great about an RDP connection to a virtual machine? Say you have an older computer without enough raw speed or RAM to run the latest operating systems and applications. Using RDP, you can turn that machine into a graphic terminal, with access to any operating system you can install in VirtualBox on your more powerful computer. Or maybe you just want to have instant access to a VM running a different operating system, from anywhere on your network.
Server Configuration in Ubuntu #
Authentication is the main hurdle to sharing a VirtualBox VM with RDP. VirtualBox’s RDP server needs to know what port to listen on, and what authentication method to use. Even if you don’t care about security, you may need to configure it anyway: In Ubuntu, I could not get RDP to work with the default “Null” setting. So the first step is to open your VM’s Display settings, click on the Remote Display tab, checkmark the “Enable Server” box, and change the Authentication Method to “External”.
You can leave the Port set to the standard (3389) unless you need to run multiple RDP sessions simultaneously. In that case, each VM must use a different port number.
Next, you’ll need to to create an external authentication service. This is just a matter of changing some settings. Go to the /etc/pam.d directory and create a file called vrdpauth
with these lines:
auth required pam_unix.so
account required pam_unix.so broken_shadow
Execute the export
command to set the VRDP_AUTH_PAM_SERVICE environment variable. Add it to ~/.bashrc so that it’s automatically set the next time you log in:
export VRDP_AUTH_PAM_SERVICE=vrdpauth
Last, start the VM – either normally, or from the command line. The latter method runs the VM “headless” (no display), and waits for a connection. This makes it perfect for automated startup and especially if you’re running VirtualBox on a pure server that doesn’t run X-Windows or a GUI desktop. The command to start a headless VM is:
VBoxHeadless --startvm <uuid|name>
Client Configuration: Rdesktop #
If your client PC runs Linux, rdesktop is probably your best option. Most GUI apps in Linux like “Terminal Services Client” are just wrappers around rdesktop. It’s worth getting familiar with the rdesktop parameters, particularly if you need to troubleshoot your connection. Test it first on the same machine hosting the VM, with a command like the following:
rdesktop -a 16 -u john -p - localhost:3389
In this example, “16” is the bits per pixel, “john” is the username, “localhost” is the machine serving the VM, and “3389” is the port number. The username must exist on the host. Also, note the hyphen after “-p”, which will prompt for the password.
If your test works, run the same command from your client PC, replacing “localhost” with the hostname or IP of the server. Now, you can enjoy the latest applications, even on underpowered computers. I’ve used RDP to connect from my aging Thinkpad A20 laptop (Pentium III, 700 mhz CPU). Aside from streaming video, it runs with suitable speed.
The main limitation is the screen resolution on the client. If 1024x768 is the most it can do, then set your VM’s resolution to the same. Use Ctrl-Alt-Enter to toggle fullscreen mode and get rid of the scroll bars.
For more about RDP in Virtualbox, download the VirtualBox PDF user manual or read it online.