Skip to content

Hardening Kali Linux

Although Kali Linux is notorious for being the distro of choice for penetration testers, hackers, and cyber security experts, it doesn’t mean that the operating system is not also vulnerable to exploits.

If you are new to Kali Linux or to penetration testing in general, the first step is to learn how to secure your own system, before attacking others. In this tutorial, you will learn of various steps that can be taken in order to harden Kali Linux for increased security.

In this tutorial you will learn:

  • How to harden Kali Linux, best practices
  • How to install software to scan Kali for vulnerabilities
  • More software and security precautions to take on Kali
Hardening Kali Linux
Hardening Kali Linux
CategoryRequirements, Conventions or Software Version Used
SystemKali Linux
SoftwareN/A
OtherPrivileged 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

How to harden Kali Linux



Follow along with the sections below in order to see various ways to harden your Kali Linux system. You don’t want to be the hacker who gets hacked.

Use secure passwords

Hopefully you already knew this one. It’s important to use secure passwords for both your normal user account and your root user. You probably don’t need any other user accounts in addition to this, since Kali should be used exclusively for security testing and not as a multi user system.

To update your password, execute:

$ passwd

To update your root password, execute:

$ sudo passwd

Keep Kali up to date

Security vulnerabilities are found in Linux systems and its various software packages all the time. As someone using Kali, you are probably hoping to exploit a few of these yourself.

One of the best way to protect yourself from newly found vulnerabilities, such as zero day exploits, is to simply keep your system up to date. This is super easy to do in Kali with the apt package manager. Execute the commands below to upgrade all the software on your system to the latest versions.

$ sudo apt update
$ sudo apt full-upgrade

When done, you can remove unnecessary packages and free up disk space with this command:

$ sudo apt autoremove

Change SSH keys

If you downloaded your Kali Linux image or virtual machine from online, and didn’t actually go through the installation process yourself, you should consider changing the SSH keys for your user. Otherwise, hundreds of other users could also be using the same keys, and exploit your login.

Execute the following command to change the SSH keys on Kali:

$ dpkg-reconfigure openssh-server

If you don’t need to SSH into your Kali Linux machine at all, then it’s probably best to simply remove the OpenSSH server package entirely. This gives attackers one less way to infiltrate your system.


https://29b413b220e1905e2b132790bd640054.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.html

$ sudo apt remove openssh-server

Don’t always use the root account

Since Kali is not meant as a daily driver, it can be tempting to throw usual guidelines out the window, and simply use the root account for almost everything. This is frowned upon in any other system, but Kali seems to faciliate this behavior.

For example, it’s possible to login to the GUI with root account on Kali. It’s very easy to do, and the developers even included a package that can easily be installed in order to enable this setting.

If you’re trying to keep your Kali Linux install as secure as possible, it’s recommended that you stick with your unprivileged user whenever possible, especially when launching the GUI.

Check for rootkits, backdoors, and exploits

The rkhunter software package can be installed on Kali, and then used to check for rootkits and other exploits on the system. Execute the following command to install it with the system’s package manager.

$ sudo apt install rkhunter

Then, run the following command to begin checking for rootkits, backdoors, and exploits:

$ sudo rkhunter -c

The output will print any issues that it thinks need to be fixed or deserve a closer look.

Another useful utility is chkrootkit, which can check for rootkits. Execute the following command to install it with the system’s package manager.

$ sudo apt install chkrootkit

Then, run the command without any options to begin checking your system for rootkits.

$ sudo chkrootkit

More Kali Linux Hardening Methods

The amount of other software available in Kali’s repositories that can be installed to harden the system is simply staggering. There are a ton of different tools, but we’ve covered some of the most essential in this tutorial. We’ve compiled a short list of other software that is worth checking out, along with some other similar tutorials that we’ve written for Linux security.

More reading:


https://29b413b220e1905e2b132790bd640054.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.html

More Kali Linux hardening tools

These tools can also be installed from the default Kali repos, with the apt command.

  • firejail – security sandbox
  • lynis – security auditing tool
  • samhain – host intrusion detection system
  • tripwire – checks the integrity of files

And many, many more… Remember you can always search for extra packages on Kali from the command line or a GUI software installer. Check out the other tutorial to see how.

Closing Thoughts

In this tutorial, we saw various steps that can be taken to harden a Kali Linux system. It’s easy to forget about the security of your own system when you’re busy trying to exploit the security of others. That’s why hardening Kali is so important. Be sure to follow the steps mentioned here, ensuring the security of your own system, before you bother trying to hack into others.

Leave a Reply