Run VirtualBox headless over an SSH session

When SSH’ing into a linux box, you may want to run a VM headless (that is, not dependent on the console X session). TO RDP into your windows box (assuming you are running a Windows VM over Linux), you’ll want to be sure to engage your -L port:ip-address-of-VirtualBoxHost:port, port forwarding.

Assuming you have VirtualBox remote port forwarding engaged (which will forward ports into the VM, for example if you’re running Windows XP as a VirtuaBox VM and you want to RDP into it on port 3389), I discuss port forwarding on VirtualBox hosts, here. Though VirtualBox supports a quick and easy VRDP option to enable for easy RDPing into a box without having to do any of the complex port forwarding, my port-forwarding post explains how to forward other ports to your VM for any other applications or if you want to RDP into your Windows VM on a port other than 3389.

To engage the VM over an SSH session, simply type:

VBoxHeadless -startvm "Name of VM Here"

You can also force VirtualBox’s VRDP (virtual RDP) via command line by adding the switch “–vrdp on”, though it’s usually on by default.

If you’re not sure of the name of the VM, simply type

VBoxManage list vms

Once running, you can simply run …

rdesktop localhost:3389

Assuming you have a -L 3389:ip-address-of-VirtualBox-host:3389 in your original SSH command, and you can now RDP into your Windows XP box which would be running in a VM over Linux.

Source: HowToForge