Kali Linux Cloud Init Image
Published: 2022-04-08
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.
sudo apt install -y libguestfs-tools p7zip-full p7zip-rarBuild Image
We will be converting the VMware image, so let's download the image to our local machine.
wget https://kali.download/virtual-images/kali-2022.1/kali-linux-2022.1-vmware-amd64.7zUnpack the image.
7za x kali-linux-2022.1-vmware-amd64.7zConvert the image from VMDK format to RAW format.
qemu-img convert -f vmdk -O raw kali-linux-2022.1-vmware-amd64.vmwarevm/kali-linux-2022.1-vmware-amd64.vmdk kali-2022.1.imgNow we need to customize the image to make it configurable with cloud-init.
sudo virt-customize -a kali-2022.1.img --install cloud-initInstall qemu-guest-agent so that the guest can be controlled by the hypervisor.
sudo virt-customize -a kali-2022.1.img --install qemu-guest-agentBy default, the SSH service is disabled. I want to SSH to the VMs when I build them, so I am enabling the SSH service.
sudo virt-customize -a kali-2022.1.img --run-command 'systemctl enable ssh.service'Finally, let's update the image with the latest packages.
sudo virt-customize -a kali-2022.1.img --updateAnd 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 ✌️
Links
https://techglimpse.com/convert-vmdk-qcow2-openstack-kali/
https://docs.openstack.org/image-guide/convert-images.html
https://www.kali.org/get-kali/#kali-virtual-machines
https://manpages.ubuntu.com/manpages/xenial/man1/virt-customize.1.html