Would you like to harness the power of Kali directly from the command line?
If the answer is yes, this post is for you.
If not, that’s fine too.
Dependencies Link to heading
Building Link to heading
Kali provides this guide to building a Kali virtual machine.
Adding the line vb.gui = false
allows the vm to be created without GUI and ran directly in the shell.
Create the Vagrantfile
below:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "kalilinux/rolling"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network "public_network""
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# config.vm.synced_folder "/Users/<username>/.ssh", "/home/vagrant/.ssh"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = false
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
end
#
config.vm.provision "shell", inline: <<-SHELL
sudo rm /etc/motd
sudo rm /etc/update-motd.d/*
SHELL
end
Usage Link to heading
Add these aliases to your ~/.profile
or ~/.bashrc
for easy control.
Note: Make sure to edit the path to match your Vagrantfile directory location.
# Kali
alias kali-go="cd ~/vagrant-vms/kali/ && vagrant up && vagrant ssh && cd -"
alias kali-up="cd ~/vagrant-vms/kali/ && vagrant up && cd -"
alias kali-ssh="cd ~/vagrant-vms/kali/ && vagrant ssh && cd -"
alias kali-reload="cd ~/vagrant-vms/kali/ && vagrant reload && cd -"
alias kali-provision="cd ~/vagrant-vms/kali/ && vagrant provision && cd -"
alias kali-halt="cd ~/vagrant-vms/kali/ && vagrant halt && cd -"
alias kali-destroy="cd ~/vagrant-vms/kali/ && vagrant destroy -f && cd -"
Notes Link to heading
If you want to use the ssh keys from your host machine, uncomment the config.vm.synced_folder
line and replace <username>
with your username/home directory.
You will be asked when building or reloading the vm which network you’d like to bridge to.
If you have network issues, use ifconfig
to to see the network intefaces and try pinging each one. Then try pinging google.com
and 8.8.8.8
. If you’re only unable to ping google.com, its a DNS issue that can be resolved by updating the nameservers in /etc/resolv.conf
with 8.8.8.8
and restarting the networking service with sudo /etc/init.d/networking restart
.