Did you know that you can now manage Kali Linux Virtual instance with Vagrant?. Being a huge fan of Kali Linux, I’m happy to share with you a process of running Kali Linux with Vagrant & VirtualBox hypervisor. Kali Linux is the leading advanced Penetration Testing and Security Auditing Operating system based on Debian.

Kali Linux contains several hundred tools geared toward computer Forensics, Penetration Testing, Reverse Engineering, Security research. Kali development is funded and maintained by Offensive Security, a leading information security training company.

For those new to Vagrant, Vagrant is an open source tool for building and managing virtual machine environments in an easy-to-use single workflow.

Setup Requirements

  • Any decent Linux distribution – Debian, Ubuntu, Arch, Fedora e.t.c
  • CPU with VT-X/AMD Virtualization extensions
  • VirtualBox and Vagrant installed

Step 1: Install Vagrant and VirtualBox

To install Vagrant and VirtualBox, refer to our previous guides:

How to install latest VirtualBox on Kali Linux Rolling

How to install the latest VirtualBox on Ubuntu / Debian

Install Latest Vagrant on Ubuntu / Debian & Kali Linux

Step 2: Download Kali Vagrant box

After installing VirtualBox and Vagrant, download Kali Linux Vagrant box image. You have two options for this.

  1. Download Kali Linux full image – comes with all Kali packages
  2. Download Kali Linux Light – contains stripped down package list

Download Vagrant box using the command:

$ vagrant box add kalilinux/rolling
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) virtualbox
2) vmware_desktop
Enter your choice: 1
==> box: Adding box 'kalilinux/rolling' (v2021.2.0) for provider: virtualbox
    box: Downloading: https://vagrantcloud.com/kalilinux/boxes/rolling/versions/2021.2.0/providers/virtualbox.box
==> box: Box download is resuming from prior download progress
==> box: Successfully added box 'kalilinux/rolling' (v2021.2.0) for 'virtualbox'!

You can as well specify provider in the command line:

# VirtualBox 
$ vagrant box add kalilinux/rolling --provider virtualbox

# VMware
$ vagrant box add kalilinux/rolling --provider vmware_desktop
==> box: Loading metadata for box 'kalilinux/rolling'
    box: URL: https://vagrantcloud.com/kalilinux/rolling
==> box: Adding box 'kalilinux/rolling' (v2021.2.0) for provider: vmware_desktop
    box: Downloading: https://vagrantcloud.com/kalilinux/boxes/rolling/versions/2021.2.0/providers/vmware_desktop.box
Progress: 1% (Rate: 4634k/s, Estimated time remaining: 0:19:57)

The added Vagrant boxes should be visible from

$ vagrant box list
kalilinux/rolling       (virtualbox, v2021.2.0)
kalilinux/rolling       (vmware_desktop, v2021.2.0)

Step 3: Start Kali Linux virtual machine

Start by  creating an empty directory  for Kali project and then generate a Vagrant file from there:

$ mkdir -p vagrant-projects/kali
$ cd vagrant-projects/kali
$ vagrant init kalilinux/rolling

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

This command generates a Vagrantfile for you which contains all the configuration options for the virtual machine. It is worth knowing that every vagrant command should be run from the directory containing Vagrantfile.

You can modify the file to your liking before running the vagrant up command:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "kalilinux/rolling"
  config.vm.box_check_update = false
  config.vm.hostname = "kali-linux"
  config.vm.provider "virtualbox" do |vb|
  # Display the VirtualBox GUI when booting the machine
     vb.gui = false
     vb.memory = "2048"
  end
end

When done with the modifications, save the file and run

$ vagrant up

Here is a sample output

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /home/jmutai/hacks/vagrant/labs/kali
    default: /vagrant_data => /home/jmutai/Projects

To access the VM shell, run:

$ vagrant ssh

You can also use your host ssh client and access the Kali Linux instance shell through assigned private IP address.

$ ssh [email protected]
Warning: Permanently added '192.168.90.99' (ECDSA) to the list of known hosts.
[email protected]'s password: 
Linux kali 4.18.0-kali1-amd64 #1 SMP Debian 4.18.6-1kali1 (2018-09-10) x86_64

The programs included with the Kali GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Oct 19 15:20:41 2018 from 10.0.2.2
[email protected]:~$

If you check instance IP addresses, the one configured on Vagrantfile should be available.

kali linux vagrant ip address min

Whenever you make a change to the Vagrantfile, restart the machine for the changes to take effect.

$ vagrant reload

To stop the instance, use

$ vagrant halt

If you would like to save the current state of the VM while stopping it, use

$ vagrant suspend

With this, you’ll return to exactly the same state at a later time when VM is started.

Destroy the Vagrant machine when done  by running

$ vagrant destroy

Wrapping Up

In this guide, we have shown you how to manage Kali Linux instance with Vagrant. Don’t forget to check out the official documentation for more Vagrant configuration options.

More on Virtualization:

How to Install VMware Workstation on Arch Linux / Manjaro

How To Install Proxmox VE 6 on Debian 10 (Buster)

How to extend/increase KVM Virtual Machine (VM) disk size

How to Monitor VMware ESXi with Grafana and Telegraf

Top Cyber Security Learning Video Courses:

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

2 COMMENTS

  1. :~/vagrant$ vagrant box add offensive-security/kali-linux-light

    “The box ‘offensive-security/kali-linux-light’ could not be found or could not be accessed in the remote catalog. If this is a private box on Hashicorp’s Vagrant Cloud, please verify you’re logged in via ‘vagrant login’ Also, please double-check the name. The expanded URL and error message are shown below:

    URL: [“https://vagrantcloud.com/offensive-security/kali-linux-light”]
    Error: The requested URL returned error: 404 Not Found

    I run vagrant most days at work so I know I have it properly downloaded. Am I missing something?

    Great article nonetheless.

    • Noted the same. It seems Vagrant account originally named offensive-security was changed to kalilinux and boxes now called kalilinux/rolling.

      We’ve updated our article to reflect the same.

LEAVE A REPLY

Please enter your comment!
Please enter your name here