How to manage VirtualBox VMs on a remote headless server

Last updated on September 24, 2020 by Dan Nanni

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, Linux 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:

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.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean