All the Ways VirtualBox Remote Access Fails 🙂

Why?

So, over the past few years, I have moved my Home Lab from ESXi & Proxmox to Kubernetes on Linux and finally to Docker on Linux. I have very little need for virtual machines these days, except to try out cool distros (like Garuda) or desktop environments (like Budgie). KVM is the natural path for VMs on Linux, but I find the creation of bridged networks a PITA (I like to access my VMs on the same subnet). VirtualBox makes placing VMs on a bridged network a piece of cake.

The only issue is that my Linux server is headless, so I cannot easily get remote access to VirtualBox. I used to use an HDMI dongle that would allow this, but I have since moved to a KVM switch as I need a USB keyboard to reboot off of USB once a week to back up with CloneZilla.

I figured, "There must be a remote/web access solution for VirtualBox". Well, there are a few, and they all fail. Or, maybe they just fail for me - PEBKAC.

What?

When I researched remote access to VirtualBox, I found two solutions:

1) phpVirtualBox

2) RemoteBox

3) (I finally ended up with redirected X11)

How?

phpVirtualBox

I used the excellent tutorial here.

Here are the commands I ran in a fresh Debian 12 VM that I called phpvirtualbox:

sudo apt-get install apache2 libapache2-mod-php php php-soap php-xml
wget https://github.com/phpvirtualbox/phpvirtualbox/archive/master.zip
cd /var/www/html
sudo unzip ~/Downloads/master.zip
sudo mv phpvirtualbox-master/ phpvb
cd phpvb
sudo cp config.php-example config.php
sudo vi config.php

/* Username / Password for system user that runs VirtualBox */
var $username = 'dennis';
var $password = 'SuperSecretPassword';

/* SOAP URL of vboxwebsrv (not phpVirtualBox's URL) */
var $location = 'http://192.168.1.11:18083/';

Then, I started the VirtualBox web server on my physical Linux host with this command:

vboxwebsrv --host 192.168.1.11

When I logged in as admin/admin at http://phpvirtualbox/phpvb, I was greeted with this error: "This version of phpVirtualBox (5.2-1) is incompatible with VirtualBox 7.1.6".

I searched and searched forums until I found that someone had forked phpvirtualbox and got it working with VirtualBox 7.1. That GitHub repo is here. So, I tried that version of phpVirtualBox:

cd /var/www/html
sudo wget https://github.com/studnitskiy/phpvirtualbox/archive/main.zip
sudo mv phpvirtualbox-master phpvbgit
cp phpvb/config.php phpvbgit

Now, when I opened http://phpvirtualbox/phpvbgit, I can connect to and access VirtualBox in a web browser. I could not get console access to my VMs, no matter what I tried. This meant that I could not install new VMs. Oh, well.

RemoteBox

So, RemoteBox is a lovely Perl program that is easy to install (on any OS that supports GTK+) and has an app version and a web version. RemoteBox also gave me a hard time with console access due to a cert issue I could not resolve. Here is how I installed RemoteBox in a Debian VM using these instructions:

sudo apt install libgtk3-perl libsoap-lite-perl freerdp2-x11 tigervnc-viewer
sudo apt install libregexp-common-perl
cd ~/Downloads
wget https://remotebox.knobgoblin.org.uk/downloads/RemoteBox-3.5.tar.bz2
bunzip2 RemoteBox-3.5.tar.bz2
tar xvf RemoteBox-3.5.tar
cd RemoteBox-3.1/
./remotebox 

Nice. That wasn't so hard. Now let's try a console...

I spent some time searching and trying a few things, but could not get past this error. Oh, well.

X11 Redirection

A good hack that worked. I used ssh X11 redirection to run the VirtualBox program on the host, but have the display sent to my client. This worked better on Linux than on macOS XQuartz

ssh -Y [email protected]
export XAUTHORITY=$HOME/.Xauthority
/usr/lib/virtualbox/VirtualBox 

Worked like a charm; even console access. Yay.

Thank You

Thanks for reading this post. I hope this saves someone some time and aggravation. I welcome your comments.