Kali Linux is an extremely useful tool for penetration testing. Used by cybersecurity experts around the globe, it is an essential piece of equipment with unique capabilities. Unfortunately, though, it is quite heavy-duty. If you don’t have much space on your personal computer, it can be a pain to keep it installed locally. In this article, I will show you how to create a custom Kali Linux Google Compute Engine instance, accessible through SSH.
Before you begin, make sure you have to have a Google Cloud project to which you would like to import the instance. You should also have installed VirtualBox (https://www.virtualbox.org/wiki/Downloads) as well as the Google Cloud SDK (https://cloud.google.com/sdk/) to your machine. Once you’ve done these things, you can begin.
Download Kali Linux
First, download a Kali Linux VirtualBox instance from https://www.offensive-security.com/kali-linux-vm-vmware-virtualbox-image-download/. Once you have downloaded the distribution, open it in VirtualBox. Finally, launch the machine.
Configure SSHD service
To be able to SSH to the machine when it is imported onto Google Compute Engine, we need to make sure the machine launches into SSH when it boots. To do this, enter the following command into a terminal inside the Kali Linux machine:
apt-get install openssh-server
Now that you’ve installed
openssh-server you can configure the machine to allow for an SSH connection to be made without a password. Don’t worry, your machine will still be secured through Google Cloud Platform; nobody can log in if they don’t have your password. Enter the following command:
#PermitRootLogin prohibit-password to
PermitRootLogin yes to allow for an SSH connection without a password. To set SSH to run on boot, enter this command:
update-rc.d ssh enable 2 3 4 5
Now that the machine can be connected to effectively via SSH, it’s time to package it up and create the Google Cloud Compute instance.
Upload image to Google Cloud
To import the image to Google Cloud, we must first create a Google Cloud Storage bucket to upload the instance to before importing it on the Compute engine. To do this, run this command:
gsutil mb gs://[BUCKET_NAME]/
Now that you’ve created your bucket, you can upload the image to Google Cloud. To do this, navigate to the directory in which the image is stored.
~/VirtualBox\ VMs is the default directory for VirtualBox images. You can also find the path of the image inside the VirtualBox application. Once you have changed to this directory, run the following command:
gsutil cp [IMAGE_NAME].vmdk gs://[BUCKET_NAME]/[IMAGE_NAME].vmdk
Once the file has been uploaded to Google Cloud, you are ready to import it on Compute Engine.
Import image to Google Compute Engine
This is the easy part. To create the virtual machine on Compute Engine, run this command:
gcloud compute images import my-imported-image \
--source-file gs://[BUCKET_NAME]/[INSTANCE_NAME].vmdk \
And that’s all! Now that you have successfully uploaded the image to Google Compute Engine, go to https://console.cloud.google.com/compute to connect to it via SSH.