Raspberry Pi Kali Linux headless setup

Kali Linux is one of the many operating systems that has full support for the Raspberry Pi, thanks to the ARM installer images. Combining Kali with a Raspberry Pi essentially gives you a portable penetration testing machine. Kali Linux can be installed and run without a monitor, keyboard, or mouse, so you will not need to worry about plugging in any peripherals to the Raspberry Pi.

In this tutorial, we will go over the step by step instructions to install Kali Linux as a headless setup on a Raspberry Pi. You will need access to a separate machine to prepare the SD card with the operating system and necessary settings, but this is the only prerequisite. The final result will be a Raspberry Pi that runs Kali Linux, and you will be able to interact with the device via SSH and VNC remote desktop. Let’s get started!

In this tutorial you will learn:

  • How to download Raspberry Pi imaging tool
  • How to install Kali Linux on a Raspberry Pi
  • How to enable SSH for headless Kali Linux setup
  • How to start using Kali Linux headless
  • How to configure Wi-Fi for Kali Linux from command line
  • How to configure VNC server on Kali Linux
Raspberry Pi Kali Linux headless setup
Raspberry Pi Kali Linux headless setup
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Raspberry Pi, Kali Linux
Software Raspberry Pi imaging tool, OpenSSH, Tight VNC Server
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install Kali Linux on SD Card



NOTE
This part of the tutorial can be done on any system, but you will need a GUI. You can use the Raspberry Pi imaging tool from any operating system. If you are running Windows, MacOS, or Linux, you do not need to worry about compatibility because the imaging tool works on all of them.
  1. The first thing we will need to do is install the Kali Linux operating system onto SD card (or microSD card for newer Raspberry Pi models). For this, we can use the official Raspberry Pi imaging tool, which can be downloaded from the Raspberry Pi website.
    Downloading the Raspberry Pi OS imaging tool
    Downloading the Raspberry Pi OS imaging tool
  2. Install the Raspberry Pi imaging tool. On Debian based Linux systems (including Raspberry Pi OS) the command would be:
    $ sudo apt install ./imager*.deb
    
  3. Open up Raspberry Pi imager and click on ‘Choose Device’ to the left. This will allow us to choose which Raspberry Pi model we are working with.
    Raspberry Pi imaging tool menu
    Raspberry Pi imaging tool menu
  4. Next, click on ‘Choose OS’ to the left. This will allow us to choose which operating system we want to install to our micro SD card and subsequently run on the Raspberry Pi.
    Click on the 'Choose OS' button on the menu
    Click on the ‘Choose OS’ button on the menu
  5. Now it is time to choose the operating system we want to install. Within this menu, click on the ‘Other specific purpose OS’ option.

    Navigating to the specific purpose OS options
    Navigating to the specific purpose OS options



  6. Click on Kali Linux to expand the list of Kali installation options.
    Choose to install Kali Linux on Raspberry Pi imager tool
    Choose to install Kali Linux on Raspberry Pi imager tool
  7. Click on the Kali Linux option that corresponds to your Raspberry Pi model and CPU architecture. For all recent models, this should be the 64 bit version.
    Choose which Kali Linux OS image you wish to install
    Choose which Kali Linux OS image you wish to install
  8. Lastly, choose the storage device you wish to install to (the inserted micro SD or SD card), and allow the installation to continue. Note that the Raspberry Pi imager tool will download Kali Linux from online, so the process could take a little while to complete. Once it is finished, we can move onto the next section.
    Selecting the storage device for the Raspberry Pi imager tool to use
    Selecting the storage device for the Raspberry Pi imager tool to use

Configure Headless Kali Linux Setup

Once the Raspberry Pi imager tool has completed the installation of Kali Linux on our SD card, we will need to make a single configuration file to ensure that SSH will already be enabled the first time the system boots up. After all, we are not expecting to use any peripherals (monitor, keyboard, mouse) with the system, so we will need a way to access the device once it is powered on. We expect to do that with SSH.

With the SD card still inserted into your PC, and mounted somewhere on the file system, navigate to it and generate an empty file called SSH. In the example below, we have our SD card mounted at /mnt/pi. Change yours accordingly, but use the following touch command syntax.

$ sudo touch /mnt/pi/ROOTFS/SSH

What this command will do is generate an empty file named SSH inside the root / directory of the Kali Linux file system. This simple file will instruct Kali to enable SSH for the default user the first time that the system boots up.

SSH into Kali Linux

At this point, you can eject the SD card from your main PC and insert it into the Raspberry Pi. Then, turn on the device and boot into Kali Linux. Of course, if your setup is completely headless, then you will not know for sure what is happening. But, give it a few minutes, and we will assume that Kali Linux has fully loaded and we can now SSH into the system.

The first challenge we face is figuring out the IP address of the Raspberry Pi. This is a little harder to do than usual, since we do not have a screen. We recommend either using nmap to scan your local network for devices, or login to your router and see what IP address has been assigned to the Raspberry Pi.

Once you have the IP address, we can log into Kali on the Raspberry Pi:

$ ssh kali@192.168.1.25

Note that the default username is kali and the default password is also kali.

Once logged in, we should change the password for the default account:

$ sudo passwd kali

Connect to Wi-Fi in Headless Kali Linux

The easiest way to configure your Wi-Fi connection is by using the kalipi-config utility. This is basically the same tool as the raspi-config utility on Raspberry Pi OS.

$ kalipi-config

Navigate to the ‘Networking Options,’ and then ‘Wi-Fi.’

Configuring Wi-Fi connection on Raspberry Pi
Configuring Wi-Fi connection on Raspberry Pi

From there, just enter your SSID and Wi-Fi password to get connected. After that is successful, you can yank out the Ethernet cord and still stay connected to your local network.

Install VNC Server on Headless Kali

  1. To use remote desktop on Kali Raspberry Pi, let’s install Tight VNC Server.


    $ sudo apt install tightvncserver
    
  2. Next, let’s create the login credentials for our VNC connection. Execute the following command, and then you will be required to supply a new password and verify it once more. You can optionally create a view-only password as well, if you would like to.
    $ vncserver :1
    
    You will require a password to access your desktops.
    
    Password: 
    Verify: 
    Would you like to enter a view-only password (y/n)? n
    
  3. You can now use your VNC viewer application on your main PC or other device to connect to the Raspberry Pi via IP address and use Kali Linux via remote desktop. Note that the default listening port is 5901 for the first display. So, to connect to the device, you would format the IP address like this:
    192.168.1.25:5901
    

    Of course, replace 192.168.1.25 with the actual IP address of your Raspberry Pi.

Closing Thoughts




In this tutorial, we saw how to install Kali Linux as a headless setup on a Raspberry Pi system. Who ever said that it was necessary to have a monitor, keyboard, or mouse to use a computer? As seen here, we have a fully functional, palm sized, Kali Linux PC that we can use for all our penetration testing needs, and without any need for extra peripheral devices. By using SSH and VNC, we can effectively use Kali Linux and manage the system much the same way we would on a full fledged PC.