How to manage VirtualBox VMs on a remote headless server

Most VirtualBox users may think that VirtualBox is only intended for use in a desktop environment, where virtual machine (VM) management is done via VirtualBox GUI. However, VirtualBox can in fact run on headless servers, and VirtualBox VMs launched in headless mode can be managed remotely from an external VirtualBox front-end client.

In this tutorial, I will explain how to manage VirtualBox VMs on a remote headless server.

For remote management of VirtualBox, you can use RemoteBox, which is an open-source VirtualBox client software. RemoteBox allows you to connect to a remote headless server where VirtualBox is installed, and to manage and interact with VirtualBox VMs.

For this setup, you need at least one headless server host where VirtualBox is installed. You also need a separate Linux desktop host as a VirtualBox client host. RemoteBox will be installed on the client host.

Configure VirtualBox Server

On the headless server side, you need to install VirtualBox 4.2.0 and higher.

Besides VirtualBox, you also need to install VirtualBox extension pack on the server. The extension pack is needed for remote desktop display and PXE booting.

Assuming that the version of the installed VirtualBox is 4.2.16, you can install the corresponding VirtualBox extension pack on the server as follows.

$ wget http://download.virtualbox.org/virtualbox/4.2.16/Oracle_VM_VirtualBox_Extension_Pack-4.2.16-86992.vbox-extpack
$ sudo VBoxManage extpack install ./Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack

Finally, you need to set up VirtualBox web service on the server, so that VirtualBox clients such as RemoteBox can communicate with VirtualBox remotely.

Before doing that, first determine which Linux user VirtualBox web service will run as. If you run VirtualBox web service as a particular Linux user, you can only control VMs run by the same user.

Here I will create a new user (e.g., vbox), and a new group (e.g., vboxusers) dedicated to VirtualBox web service.

$ sudo groupadd vboxusers
$ sudo useradd -g vboxusers vbox

To configure VirtualBox web service on the server, proceed as follows.

First, create a configuration file for the web service at /etc/default/virtualbox.

$ sudo vi /etc/default/virtualbox
VBOXWEB_USER="vbox"
VBOXWEB_TIMEOUT=0
VBOXWEB_LOGFILE="/var/log/vboxwebservice.log"
VBOXWEB_HOST="10.0.0.121"

In the configuration file, VBOXWEB_USER is set to the Linux user that you will run VirtualBox web service as, and VBOXWEB_HOST corresponds to the IP address of the server.

Next, initialize and set the ownership of the log file:

$ sudo touch /var/log/vboxwebservice.log
$ sudo chown vbox:vboxusers /var/log/vboxwebservice.log

Create VirtualBox configuration directory:

$ sudo mkdir /home/vbox/.VirtualBox
$ sudo chown vbox:vboxusers /home/vbox/.VirtualBox

Start VirtualBox web service:

$ sudo service vboxweb-service start

Check the status of VirtualBox web service:

$ sudo service vboxweb-service status
Checking for VBox Web Service ...running

Also, verify that VirtualBox web service is listening on port 18083.

$ sudo netstat -nap | grep vboxwebsrv
tcp        0      0 10.0.0.121:18083        0.0.0.0:*               LISTEN      15855/vboxwebsrv
unix  3      [ ]         STREAM     CONNECTED     152848   15855/vboxwebsrv

This completes VirtualBox server configuration. Next, proceed to install RemoteBox on a client host.

Requirements for Installing RemoteBox on Client Host

For RemoteBox to communicate with the server properly, the server and client hosts are NOT required to run the same operating system.

Prior to running RemoteBox on a client host, there are several prerequisite packages that you must install first.

To install prerequisites on Ubuntu, Mint or Debian based client host:

$ sudo apt-get install libgtk2-perl libsoap-lite-perl rdesktop

To install prerequisites on Fedora, CentOS or RHEL based client host:

$ sudo yum install perl-Gtk2 perl-SOAP-Lite rdesktop

Install and Configure RemoteBox on Client Host

To run RemoteBox on a client host, download its binary package from its official website, and simply run remotebox command.

$ wget http://knobgoblin.org.uk/downloads/RemoteBox-1.5.tar.gz
$ tar xvfvz RemoteBox-1.5.tar.gz
$ cd RemoteBox-1.5
$ ./remotebox

The screenshot of Remotebox looks like the following. To connect to a VirtualBox server, click on "Connect" button in the tool bar.

Fill in the server information:

  • URL: http://<IP address of the server>:18083
  • Username/password: Linux user for VirtualBox web service, and its password

Once you successfully logged in to the server, you can view a list of VMs that are created on VirtualBox.

Before launching a guest VM, edit its settings in order to enable remote display for the VM.

Click on the checkbox for enabling remote display server.

Start the guest VM by clicking on "Start" button.

Upon VM's launch, RemoteBox will automatically start rdesktop to show the VM's console via a remote desktop session.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

6 thoughts on “How to manage VirtualBox VMs on a remote headless server

  1. This is nice tutorial. I failed to connect to the web service at the virtualbox server. I tried to login in the virtualbox server from terminal, and it worked fine. But, the removebox client gives the error message "Credentials are incorrect or the VirtualBox Web Service is not running at the specified URL."
    Could you please tell me what went wrong?

    Thanks,
    Abhi

      • Actually, the web service is running. I checked both the service status and the netstat. The output is exactly as given above. Is there anything with remote desktop setting in the server side?

  2. Had a similar error, cant believe I just pasted and didn't change VBOXWEB_HOST IP address.
    Verify that when you run netstat you actually see the tcp session, that resolves it.

    sudo netstat -nap | grep vboxwebsrv
    tcp 0 0 your_server_IP:18083 0.0.0.0:* LISTEN 1502/vboxwebsrv

  3. thank you for the great tutorial. I use vortualbox 4.3 and remotebox 1.8. I followed the step and it's running well :)

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *