Setting Up Kali Linux as an LXC Container
Contents
Contents
Intro
Kali Linux is the go-to linux distribution for penetration testing and CTF challenges. Whenever there was an assignment that I needed to do or a network attack that I needed to simulate I would open vmware and start my kali VM. After switching from running Windows 10 to Pop_OS! 20.04 I decided it would be a great time to explore some of the alternative methods of getting kali linux on your system such as using docker or using an LXC container.
Why LXC and not Docker?
Short answer: LXC containers are better for virtualizing systems. Docker containers in general are designed to virtualize single applications, the containers are small containing only the necessary components to serve up a specific application. By comparison we want our Kali LXC container to contain Kali linux, any packages we install or update, and anything we are working on. While it is possible to do the same thing on docker this task seems better suited for an LXC container.
What do I need to get started?
I will cover how I set it up, this is just a reference for you.
- A linux system with LXC (use LXD if you are on an ubuntu-based distro like Pop_OS!)
- The Kali Linux image from the linux containers image server
Setting Everything up
- First step is to install LXC (or in my case LXD)
|
|
- Initialize lxd (If you get permission denied issues add yourself to the lxd group.)
|
|
- Create the kali linux container
|
|
- Drop into an interactive shell on the container.
|
|
- I prepared a script that will help you with:
- Updating, upgrading and installing kali packages
- Add a kali user and configuring ssh
- Installing x2go and the kali xfce4 desktop environment
- Unfortunately wget and curl are missing so you will have to install wget before you can start. I will look into the possibility of using cloud init to do that for you.
|
|
While there are instructions on the page to get a gui on the local system I wanted to have the ability to use x2go so I can access the Kali from my laptop.
- Point your x2go or pyhocagui client to the kali container.