Deploy Kali Linux on Google Cloud

Kali Linux Offensive Security

I work a lot with cloud providers such as Amazon AWS, Azure and occasionally Google Cloud.  Personally I really like the Google Cloud  but using it as a platform for pentesting has always been a little troublesome due to the fact I can't just spin up a Kali Linux VM from a marketplace.  In this post I will show you how I create a custom Kali Linux Google Compute Engine instance.   This methods disadvantage is that it is time consuming, but the advantage is you get a custom install with everything your little heart desires.

What you need to start:

*Once you have that all downloaded install VirtualBox and Google Cloud SDK.

Assumptions on my part:
I am assuming you already have a Google Cloud account and have some idea how everything works.

Configure Kali Linux

Step 1

Open Kali Linux OVA in Virtual Box.

Login to Kali Linux with the username:  root, password:  toor

Change the root password

Step 2

Enable SSH with the following command: 

apt-get install openssh-server

Configure OpenSSH service:

Open config file:  nano /etc/ssh/sshd_config

Change #PermitRootLogin prohibit-password to PermitRootLogin yes
(save file)

Enable SSH service:  update-rc.d ssh enable 2 3 4 5

Step 3

Configure anything else you would like such as VNC or any other tools.  Make sure you set your VM's system resources such as CPU and RAM, these will translate directly to Google Compute Engine.

Shut down your Kali Linux VM.


Upload Kali Linux Image to Google Cloud

Step 1

First we must create a Google Cloud Storage bucket to upload the instance to.

To do this, run the following command:

gsutil mb gs://ImageStore/

*Feel free to name your bucket anything you want.

Step 2

Now all we have to do is upload the image into the bucket.  To do this we first need to navigate where your VirtualBox image is.  The file should end with the extension .vmdk and you can find the direct path under the General section in your VM info within VirtualBox.  In this example my image name is KALI

To upload your image, navigate to the folder containing the image and run the following command:

gsutil cp KALI.vmdk gs://ImageStore/KALI.vmdk

Now, just sit back and wait for the file copy to finish.

Import the Image to Google Compute Engine

This is the easiest part of the whole thing.  Just run the following command:

gcloud compute images import my-imported-image \
     --source-file gs://ImageStore/KALI.vmdk \
     --os debian-9

Now just log into the Google Compute Engine Console to connect to it via SSH.  Just repeat the above command anytime you want to spin up a new instance of Kali Linux.

Leave a Reply