cod*_*lom 14 ssh command-line virtualbox virtualization
我在 Ubuntu 16.04 上也有 VirtualBox 作为主机和来宾。我必须通过 SSH 命令行管理来宾(仅启动、停止),但没有找到任何可行的解决方案。
and*_*.46 24
这都可以通过VBoxManage 在建立 ssh 连接后使用来完成:
1. 列出您的 VMS:
首先使用命令列出可用的虚拟机VBoxManage list vms,我在自己的设置中说明了这一点:
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~$
Run Code Online (Sandbox Code Playgroud)
注意:如果您不确定实际运行的是哪个虚拟机,您可以使用VBoxManage list runningvms...
2. 启动虚拟机:
启动虚拟机的VBoxManage命令和选项如下:
startvm <uuid|vmname>...
[--type gui|sdl|headless|separate]
Run Code Online (Sandbox Code Playgroud)
因此,要在我的示例中启动“Trusty Tahr Clean Copy”VM,您将使用:
VBoxManage startvm "Trusty Tahr Clean Copy" --type gui
Run Code Online (Sandbox Code Playgroud)
3. 停止虚拟机:
要停止VM,您将再次使用,VBoxManage但这次有controlvm选项:
controlvm <uuid|vmname>
pause|resume|reset|poweroff|savestate|
Run Code Online (Sandbox Code Playgroud)
在我关闭“Trusty Tahr Clean Copy”VM 的示例中,命令是:
VBoxManage controlvm "Trusty Tahr Clean Copy" savestate
Run Code Online (Sandbox Code Playgroud)
这应该在 ssh 上都能很好地工作,毕竟谁需要一个 gui :)
小智 7
对于正常关闭,请使用:
VBoxManage controlvm "Name" acpipowerbutton
Run Code Online (Sandbox Code Playgroud)