Remote console access to a VirtualBox VM running on Linux

Posted on Thu 08 September 2022 in Sysadmin

Article summary: useRalativeImagePath

Assumptions:

  • You have a remote Linux machine with a VirtualBox VM and you want to access the VM console remotely.
  • The remote machine is named "vv000" and is accessible only via SSH.
  • The VM is named "jammy"

Procedure:

  1. SSH to the remote machine where the VM is located.
  2. Cleanly shut down the VM:

    vboxmanage controlvm jammy acpipowerbutton
    
  3. Configure the VirtualBox Remote Display:

    vboxmanage modifyvm jammy --vrdeport 3390
    vboxmanage modifyvm jammy --vrdeaddress 127.0.0.1
    vboxmanage modifyvm jammy --vrdeauthtype null
    vboxmanage modifyvm jammy --vrdeextpack default
    vboxmanage modifyvm jammy --vrde on
    
  4. Start the VM in headless mode:

    vboxmanage startvm jammy -type headless
    
  5. SSH again to the remote machine, this time port forwarding the RDP port:

    ssh -L 3390:localhost:3390 you@vvv0000
    
  6. On the local machine connect your RDP client to 127.0.0.1:3390