Intro

Kali is a purpose build Linux distribution for penetration testing. They have many pre-built deployment options, but unfortunately a cloud-init compatible image is not one of them. In this post, I will show you how to convert a pre-build VMware image into a cloud-init compatible image that can be used in Proxmox, OpenStack and other environments that utilize cloud-init.

The following software was used in this post.

  • Kali Linux - 2022.1
  • Ubuntu - 2004

Pre-Flight Check

Before we can prepare the image we need to install the required system tools. I am using an Ubuntu 2004 host for the conversion process.

cmd
sudo apt install -y libguestfs-tools p7zip-full p7zip-rar

Build Image

We will be converting the VMware image, so let's download the image to our local machine.

cmd
wget https://kali.download/virtual-images/kali-2022.1/kali-linux-2022.1-vmware-amd64.7z

Unpack the image.

cmd
7za x kali-linux-2022.1-vmware-amd64.7z

Convert the image from VMDK format to RAW format.

cmd
qemu-img convert -f vmdk -O raw kali-linux-2022.1-vmware-amd64.vmwarevm/kali-linux-2022.1-vmware-amd64.vmdk kali-2022.1.img

Now we need to customize the image to make it configurable with cloud-init .

cmd
sudo virt-customize -a kali-2022.1.img --install cloud-init

Install qemu-guest-agent so that the guest can be controlled by the hypervisor.

cmd
sudo virt-customize -a kali-2022.1.img --install qemu-guest-agent

By default, the SSH service is disabled. I want to SSH to the VMs when I build them, so I am enabling the SSH service.

cmd
sudo virt-customize -a kali-2022.1.img --run-command 'systemctl enable ssh.service'

Finally, let's update the image with the latest packages.

cmd
sudo virt-customize -a kali-2022.1.img --update
Note
By default, the username to login to the image is kali and an SSH keypair is required. This can of course be modified with cloud-init.

And that's it! Now, you can copy the image to your environment of choice and configure the Kali VM on boot with cloud-init .

Outro

In this post, I showed you how to convert a Kali Linux VMware VM image to a cloud-init compatible image that can be used in Proxmox, OpenStack and other environments that utilize cloud-init. Thanks for following along ✌️

# kali
# linux