Skip to content

Vagrant: first steps

Last updated on 2019-04-06

Installing Vagrant on Debian Buster

Should be no harder than:

This worked just fine for me on Debian Buster; however, if you’re using a more stable distribution, it may be prudent to heed their warning:

Beware of system package managers! Some operating system distributions include a vagrant package in their upstream package repos. Please do not install Vagrant in this manner. Typically these packages are missing dependencies or include very outdated versions of Vagrant. If you install via your system’s package manager, it is very likely that you will experience issues. Please use the official installers on the downloads page.

Source: https://www.vagrantup.com/intro/getting-started/install.html

Their downloads page can be found at https://www.vagrantup.com/downloads.html.

To install a deb package:

Initializing a Vagrant project

vagrant init debian/buster64 will create a configuration file named Vagrantfile that is pre-configured to use the debian/buster64 “box”.

Open that file in your favorite editor and take a look at some of the comments. You can learn more about Vagrantfile at https://www.vagrantup.com/docs/vagrantfile/.

Did you notice I named the project attack-vm? Here’s why:

Choosing a “box” and vagrant up

In Vagrant terms, a “box” is simply a pre-packaged VM in Open Virtualization Format (OVF) that has been uploaded to Vagrant’s servers and can be used as a base image for personalizing your own copy of that VM.

Note the following section on your Vagrantfile:

For more details about the official Debian boxes, see https://app.vagrantup.com/debian.
To search for all boxes published to Vagrant’s cloud, visit https://app.vagrantup.com/boxes/search.

Make sure the active directory is still attack-vm, then issue the command vagrant up.

vagrant up will automatically:

  1. Download the debian/buster64 VM to ~/.vagrant.d/boxes/
  2. Create a new VirtualBox VM using the downloaded VM
    • New VirtualBox VMs by default are stored at ~/Virtualbox VMs/
  3. Start the VM in headless mode using VirtualBox

Subsequent invocations of vagrant up will of course skip the download unless you’ve deleted the box.

vagrant ssh and other useful commands

Once vagrant up has done its job, you can issue vagrant ssh to automatically open an SSH session to your VM. Vagrant takes care of generating keys and logging you in automatically.

Other useful commands:

  • vagrant --help, as you’ve probably done by now.
  • vagrant <command> --help, to get help for a specific command; e.g., vagrant box --help.
  • vagrant box list shows you all downloaded boxes.
  • vagrant halt gracefully shuts down the VM; use vagrant up to start it back up.
  • vagrant suspend saves the VM state; use vagrant resume to reactivate it.
  • vagrant reload restarts the VM and re-applies everything configured in Vagrantfile.
Published inUncategorized