VirtualBox offers a neat feature called “Seamless Mode” that allows you to seamlessly integrate windows from the host and guest operating systems. This feature proves to be problematic however if the host is a Windows operating system. The alternative is to run the guest as a headless VM and port forward connections from the host to the guest. This is a lightweight solution and can achieve Windows/Linux harmony (as well as can be expected).
Assuming that you already have VirtualBox and your guest(s) setup, the first step is to list all of the VM UUIDs with the following command:
"%PROGRAMFILES%\Oracle\VirtualBox\VBoxManage" list vms > "%userprofile%\VM UUID List.txt"
That command saves the list to “VM UUID List.txt” under your home directory; we will reference it periodically. Next you will need to setup port forwarding. The below command will setup SSH forwarding, but you will need to add in the proper UUID and host port:
"%PROGRAMFILES%\Oracle\VirtualBox\VBoxManage" modifyvm "<UUID>" --natpf1 "SSH,tcp,127.0.0.1,<Host_Port>,,22"
After port forwarding is setup you can start the VM as follows:
"%PROGRAMFILES%\Oracle\VirtualBox\VBoxManage" startvm "<UUID>" --type headless
To connect to the VM’s SSH server you will need to use PuTTy . I recommend saving Putty to your home directory and creating a modified shortcut to it that will automatically establish the SSH connection:
%userprofile%\putty.exe -ssh <user>@127.0.0.1 -P <Host_Port> -pw <password>
If you decide to use SSH keys this solution will not work. Instead you will need to create a profile in PuTTY, save it, and use that link to connect to the VM. I also like to change the shortcut icon to the logo of that distro to avoid confusion in case you have several instances.
If you want to launch it on startup you have a few options:
- Put your script in the Startup folder:
- Create a registry entry:
REG ADD HKCU\Software\Microsoft\Windows\CurrentVersion\Run /f /v <Value_Name> /t REG_SZ /d "\"%PROGRAMFILES%\Oracle\VirtualBox\VBoxManage\" startvm \"<UUID>\" --type headless"
- Create a local group policy.
Lastly I like to put the shortcut in my Quick Launch. You can then easily launch the instance by hitting the windows key + the number that corresponds to its position on the Quick Launch. This solution is not ideal for me however because I sometimes like to have multiple SSH sessions to the same VM and the shortcut key just maximizes/minimizes the window once its open. My solution is to add the Quick Launch section to my %PATH% and give the shortcuts simple names, like ‘f’ for my Fedora instance. This way I can open up Run with the windows key + R then ‘f’ or ‘u’ to establish the connection:
setx PATH "%PATH%;%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
As an added bonus, here is the command to disable those pesky messages in VirtualBox:
------Share this post:
"%PROGRAMFILES%\Oracle\VirtualBox\VBoxManage" setextradata global "GUI/SuppressMessages" "all"