You can use the plethora of Vagrant Boxes available online, but there are times that you want/need to create your own Vagrant Box, based on specific requirements, with specific packages and most importantly with a specific ssh key pair.

In this guide I will walk through the process of creating a Vagrant BOX from scratch. I will be using a Mac with VMware Fusion and my Vagrant Box will be based on RHEL/CentOS.

1)Create a kickstart configuration file that you will use to automate the installation.
You can do it manually but I prefer/recommend using a kickstart file because you are software-defining the resulting machine and you can source control it. I placed the kickstart on a web server, in this case in my own Mac system so that it is reachable by the VM during installation.

root password:
You can use the password ‘vagrant‘ as is on the kickstart, or you can provide the SHA512 hash of the root password you want. You can do this in several ways from a Linux terminal

SSH key pair:
You need to create a key pair that you will use for Vagrant. The way it works is that the generated public key will be added to the authorized keys allowed to ssh as the user ‘vagrant’ in the custom Vagrant BOX while the vagrant software on the host(Mac) will use the private key to connect from the host(Mac) to the Vagrant BOX(vm)
You can create the ssh key pair as follows:

Once you have the password and SSH keys, you can use the below kickstart (replacing the password and SSH public key accordingly)

2) Creating the custom VM

Add new VM

Continue without Disc


Create a custom virtual machine

Choose RHEL6_64

Click on Customize settings


Select 1CPU and 1GB of RAM (The VM should be as minimal as possible, you can increase CPU and RAM from Vagrant)


Disable unnecessary stuff (print sharing, bluetooth, sound card)




3) Start installation

Boot VM and add the RHEL/CentOS ISO disk (Choose Disc or Disc Image…)

Point to the kickstart file served by the web server

Installation will proceed and the VM will be powered off (based on the kickstart ‘poweroff’ option)

4) Once VM is off Disable CD drive

5) Quit VMware Fusion (this is to clear the lock files so that you have a pristine VM)


6) Difragment and Shrink the VMDK


7) On the folder where the virtual machine was created, create the following metadata.json file:

8) Create the Vagrant box container

9) Add the Box to Vagrant

Note: You can also add this Vagrant Box to a webserver so that it can be shared with others, in my case I uploaded the Box to a web server:

Update: You can create a Vagrant Box Catalog that will allow versioning of the Boxes and allows the end-users/developers to get automatic update notifications when you have an updated Vagrant box: Versioning and Update Notifications for your Vagrant boxes