Friday, February 1, 2013

Controlling Virtualbox From Command Line & SSH From Host to Client

Here, I got some virtual machines on my laptop. And I would like to learn how to control them via command line. The controls I am interested in includes, "start", "power off", "save current state", etc.

Take the "Fedora" virtual machine as example.

  • VBoxManage startvm "Fedora"
    • Turn on the virtual machine
  • VBoxManage startvm "Fedora" --type headless
    • Start the virtual machine without really start the window
  • VBoxManage controlvm "Fedora" savestate
    • Save the current state of the virtual machine and turn off the window
Setting up connection from host to client using ssh is also easy.
  1. on the setting page of the virtual machine
  2. click on network tab, and add a new adapter (usually, it's adapter 2)
  3. attached to "host-only adapter", with name "vboxnet0"
    • if virtualbox shows "invalid setting" in the lower part, go to the "preference" page of virtualbox, then find "network" tab, and add a new setting by pressing the button on the right hand side
  4. start the virtual machine, and click IP by typing "ifconfig"
  5. enable ssh server on the virtual machine, you may check it work or not by trying ssh to itself
  6. ssh to the IP you saw on the client with the right username

No comments:

Post a Comment