queer activist, technologist, writer, hacker
I haven't really played around with Vagrant much, but I am a huge VirtualBox fan. Of course, it's annoying to use the GUI... lots of things to click, and the console screen has plenty of usability issues. What I really wanted was the ability to quickly turn on/off my VMs and just ssh to them.
After some poking around, I seem to have figured out a good basic system for doing exactly that via the command line. Thanks to the CLI VirtualBox documentation and a few Stack Exchange posts, here's where I've netted out. And quick note -- you can do a lot more than what I'm doing here, so I recommend taking a look at the docs which you can find here.
Start a VM -- replace NAME with the name of the VM or the ID:
vboxmanage startvm NAME --type headless
Pause, poweroff, etc. that VM:
vboxmanage controlvm NAME COMMAND
Where COMMAND is one of:
If you want to be able to ssh to your VM, you'll want to use port forwarding. The basic settings can be host port: 3022, guest port: 22, name: ssh. For multiple VMs, I just changed the host port to avoid conflicts. You can make those changing through the GUI networking section, or via command line:
vboxmanage modifyvm NAME --natpf1 "ssh,tcp,,3022,,22"
On your VM, you need to make sure you have open-sshserver or something similar installed:
sudo apt-get install openssh-server
Finally, to ssh to your VM once it's up and running:
ssh -p 3022 USERNAME@127.0.0.1
I know Vagrant essentially does this, but I've just been using VirtualBox for awhile and prefer it at the moment. Maybe one day I'll dive deeper into Vagrant. For now, this gets the job done.