I've got VirtualBox on Ubuntu 16.04 as host and guests also. I have to manage guests (start, stop only) via SSH command line, but didn't find any working solution.
-
2https://www.virtualbox.org/manual/ch08.html#vboxmanage-startvm – user4556274 Aug 01 '16 at 13:01
-
It was easier, than I thought. Sorry for OFF. There are some command line tool for kvm. One of them is "virsh". To start|stop a vm just use: $ virsh start|shutdown
(you can list by $ virsh list --all). You can use this tool in bash script or crontab for instance. Thanks for help again. – codolom Aug 03 '16 at 09:53
2 Answers
This can all be accomplished by using VBoxManage
after you have established an ssh connection:
1. List your VMS:
First list your available Virtual Machines with the command VBoxManage list vms
, I illustrate this on my own setup:
andrew@ilium~$ VBoxManage list vms
"Windows 8" {c4422acd-727b-45a0-9eef-65636bcde44d}
"Windows 10" {a8e262be-a032-4918-9085-63185318a979}
"Trusty Tahr Clean Copy" {c99bcf4b-9fea-4971-b190-425cb0b0cdeb}
"Xenial Xerus Clean Copy" {850122b9-c65f-425b-abb3-ffda68e159c6}
"Precise Pangolin Clean Copy" {169086e6-a3f4-42e7-8a89-63dcb273143f}
"Precise Pangolin Working Copy" {ff8312b6-cfae-4877-aa93-d71036d8882c}
"Xenial Xerus for MPlayer" {44902710-4368-4c06-9d24-3cb55328d31c}
"Xenial Xerus for vlc" {a62ad306-17d9-4ee3-8c1a-e4439c3b0e05}
"Xenial Xerus mingw64" {584d8513-6a16-49c7-b020-d657b93d5552}
"Trusty Tahr Working copy..." {433349e9-52eb-4066-bae7-623592871839}
"Xenial Xerus Working copy..." {dda23e74-cdb5-4c7d-8836-31be4129c02a}
andrew@ilium~$
Note: If you are unsure which VM is actually running you could use VBoxManage list runningvms
instead...
2. Start a VM:
The VBoxManage
command and options that you are after to start a Virtual Machine are these:
startvm <uuid|vmname>...
[--type gui|sdl|headless|separate]
So to start the "Trusty Tahr Clean Copy" VM in my example you would use:
VBoxManage startvm "Trusty Tahr Clean Copy" --type gui
3. Stop a VM:
To stop the VM you would again use VBoxManage
but this time with controlvm
option:
controlvm <uuid|vmname>
pause|resume|reset|poweroff|savestate|
And in my example to close the "Trusty Tahr Clean Copy" VM the command would be:
VBoxManage controlvm "Trusty Tahr Clean Copy" savestate
This should all work nicely over ssh, who needs a gui after all :)

- 38,003
- 27
- 156
- 232
-
I've tried these commands before ask. VBoxManage list vms|runningvms|anything else - empty result
Impossible. The vms are created on graphical frontend and they are running. This was the moment, when I asked help.
– codolom Aug 02 '16 at 05:16 -
@codolom Hmmm.... must be the ssh connection then. Are you connecting to your host computer from another computer via ssh? I presume you are using the ssh commandline... – andrew.46 Aug 02 '16 at 05:53
-
@codolom t is curious, I tested the information in my answer ion my own system via ssh and it worked perfectly. Does
VBoxManage list vms
give an error? – andrew.46 Aug 02 '16 at 08:31 -
I didn't know that should be a problem. I've tried to fix it this way: http://stackoverflow.com/questions/5906441/how-to-ssh-to-a-virtualbox-guest-externally-through-a-host
I hate this textbox with Ctrl+Enter :( - Sorry for missing lines.
I applied this command on console, but same results.
– codolom Aug 02 '16 at 08:32 -
-
@codolom And you are logging onto your host Ubuntu system via ssh and then trying to open and close VMs on this host system? Can you navigate around your host system ok, as in change directories run commands etc? – andrew.46 Aug 02 '16 at 08:36
-