19

Is it possible to run commands on a VirtualBox VM from outside? Or should I use some sort of remote control tool like VNC? If so, what would be the easiest and best for such a simple task. I have a Windows 7 VM inside an LMDE Linux.

2 Answers 2

22

You can use the VBoxManage guestcontrol command to run any command runnable in the guest provided you have guest additions installed.

3
  • 1
    E.g. vboxmanage guestcontrol 5e5aa334-b2d7-4a18-8bff-66df9b9770cb --username ieuser --password 'Passw0rd!' run -- cmd.exe /c whoami
    – Jellicle
    Apr 29, 2022 at 18:41
  • Does this command allows me to run an application, that appears outside the vm, for example instead of cmd.exe, I write code . ->> will this open vscode outside the vm, specially if the outside vm is a linux os.
    – CODEHUB
    Aug 6, 2023 at 17:55
  • For the vboxmanage guestcontrol command provide by Jellicle above I had to use double quotes around the password. When issuing the command with apostophes I received authentication errors.
    – Night Owl
    Mar 5 at 7:04
4

If your virtual machine is using bridged networking, then it is on the same network as the host machine. It appears to be just another computer on the network, so any remote access or remote command mechanism that works between physical machines will work here: SSH, VNC, RDP, etc.

If your VM is using NAT networking, you cannot connect directly to it over the network unless you first set up port forwarding, but thereafter it works as described above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .