Before you learn a single hacking technique, you need a safe place to practise. That means a lab: a machine you control, where you can install tools, break things and start again without touching your main computer or anyone else’s system.
Ethical Hacking Series, Part 1. This post is the first step of my ethical hacking and penetration testing series. We’ll cover why Linux and Kali matter, how virtualization makes a home lab possible on an ordinary laptop, and then set up Kali Linux in VirtualBox with SSH access and key-based login, so you can work from your own terminal instead of the VM window.
What this series will cover
This lab is the base for everything that follows in the playlist:
- Types of hackers (white hat, black hat, grey hat) and what “ethical” actually means
- The deep web and dark web, separating the facts from the myths
- Reconnaissance: gathering information about a target
- Vulnerability scanning
- Social engineering, the human side of attacks
- Using AI tools to speed up penetration testing
One rule before we start: only test systems you own, or systems you have written permission to test, such as your own lab or a bug bounty program’s in-scope targets. Scanning or attacking anything else is illegal in India under the IT Act, and in most other countries too, even if you “didn’t mean any harm”.
Why Linux, and why Kali?
Linux runs the vast majority of the world’s servers, cloud workloads and containers. If you want to attack, defend or even just understand real systems, you have to be comfortable on the Linux command line. Most of what you’ll test in your career will be running on it.
Kali Linux is a Debian-based distribution maintained by Offensive Security, built specifically for security work. It comes with hundreds of penetration testing tools already installed and configured: Nmap, Burp Suite, Metasploit, Wireshark, Hydra, sqlmap, Gobuster and many more. You can install them on any Linux system, but Kali saves you hours of setup and keeps them updated together.
Kali is a tool for security testing, not an everyday desktop. Run it in a virtual machine, not as your main operating system.
Why use a virtual machine?
Most laptops sit idle most of the time, with spare RAM and CPU cores doing nothing. Virtualization lets you use those spare resources to run a complete second operating system inside a window, isolated from your main system (the host).
- Safe: if you break Kali, or a tool misbehaves, your host OS isn’t affected.
- Disposable: take a snapshot before risky experiments and roll back in seconds.
- Flexible: run Kali alongside deliberately vulnerable VMs (like Metasploitable or DVWA) to practise attacks legally.
Recommended specs: at least 8 GB of RAM on your laptop (give Kali 2–4 GB), 2 CPU cores for the VM, around 30 GB of free disk space, and hardware virtualization (VT-x/AMD-V) enabled in your BIOS.
Step 1: Install VirtualBox
Download Oracle VirtualBox for your host OS (Windows, macOS on Intel, or Linux) from virtualbox.org and install it with the default options. VirtualBox is free and works well for a home lab. If you’re on an Apple Silicon Mac, use UTM or VMware Fusion with the ARM version of Kali instead.
Step 2: Download the pre-built Kali VM
Installing Kali from an ISO works, but there’s a faster way. Kali publishes ready-made virtual machine images:
- Go to kali.org → Get Kali → Virtual Machines.
- Download the VirtualBox image (a compressed
.7zfile). - Extract it with 7-Zip (Windows) or
7z x(Linux/macOS). - In VirtualBox, choose Machine → Add and select the extracted
.vboxfile.
Before first boot, open the VM’s Settings and adjust the memory and CPU to suit your laptop.
The default login for the pre-built image is kali / kali. Change it immediately after your first login, especially before enabling SSH:
passwd
A reality check on bug bounties
Many people start learning ethical hacking because they want to earn from bug bounties. It’s possible; I’ve been paid for valid findings myself. But it helps to understand how it works before you start:
- It’s first come, first served. If someone reports the same vulnerability before you, your report is marked as a duplicate and you get nothing, even if your finding is perfectly valid.
- Popular programs are crowded. Thousands of hunters test the same well-known targets, so the easy bugs disappear fast.
- Fundamentals win. The people who earn consistently understand networking, Linux, HTTP and how web apps really work, so they find the bugs automated scanners miss.
Treat bug bounties as a way to practise on real applications. The income follows the skills, not the other way around. For an example of what a real finding looks like, read about the XSS vulnerability I found in a bug bounty program.
Step 3: Network the VM with a bridged adapter
To SSH into Kali from your laptop, the VM needs an IP address you can reach. In VirtualBox, open Settings → Network → Adapter 1 and set Attached to to Bridged Adapter, choosing your active Wi-Fi or Ethernet interface.
With a bridged adapter, Kali joins your home network like any other device and gets its own IP from your router. Start the VM and check it:
ip a
Look for an address like 192.168.1.45 on eth0.
Which network mode should you use?
- Bridged: the VM is a full device on your LAN. It’s easy to reach, but also visible to everything else on that network. Fine at home; avoid it on office or public Wi-Fi.
- NAT: the VM can reach the internet but isn’t reachable from your network by default. This is the safest default.
- Host-only: the VM can only talk to your laptop and other VMs. This is ideal for an isolated attack lab with vulnerable machines.
Step 4: Enable SSH on Kali
Working in the VM window is clumsy: copy-paste is unreliable and switching windows slows you down. SSH lets you use your normal terminal instead. Kali doesn’t enable the SSH server by default, so install and start it:
sudo apt update
sudo apt install -y openssh-server
sudo systemctl enable --now ssh
sudo systemctl status ssh
Now connect from your host’s terminal (PowerShell on Windows, Terminal on macOS or Linux):
ssh kali@192.168.1.45
Fixing “REMOTE HOST IDENTIFICATION HAS CHANGED!”
If you’ve rebuilt the VM, or your router gave the same IP to a different machine earlier, SSH refuses to connect with this warning. SSH remembers each server’s key in ~/.ssh/known_hosts, and a different key on the same IP looks like a possible man-in-the-middle attack.
In your own lab, where you know the VM was rebuilt, remove the old entry and connect again:
ssh-keygen -R 192.168.1.45
On a real server, don’t do this blindly. Find out why the key changed first.
Step 5: Passwordless sudo (lab only)
In a throwaway lab VM, typing your password for every sudo command gets tiresome. You can allow your user to run sudo without a password. Always edit sudo rules with visudo, which checks the syntax before saving; a broken sudoers file can lock you out of root entirely.
sudo visudo -f /etc/sudoers.d/kali
Add this line and save:
kali ALL=(ALL) NOPASSWD: ALL
Putting it in its own file under /etc/sudoers.d/ keeps the main /etc/sudoers file clean. Only do this on a lab VM. On any real server, passwordless sudo means anyone who gets your user account gets full root access.
Step 6: SSH key login
Instead of typing a password every time you connect, use an SSH key pair. The private key stays on your laptop; the public key goes on Kali. It’s both faster and more secure than a password.
On your host, generate a key pair if you don’t already have one. Ed25519 is the modern default; RSA with 4096 bits also works:
ssh-keygen -t ed25519 -C "kali-lab"
# or: ssh-keygen -t rsa -b 4096 -C "kali-lab"
Copy the public key to Kali. On macOS and Linux:
ssh-copy-id kali@192.168.1.45
Windows PowerShell doesn’t have ssh-copy-id, so append the key manually:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh kali@192.168.1.45 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"
Now ssh kali@192.168.1.45 logs you straight in. If it still asks for a password, check the permissions: ~/.ssh must be 700 and authorized_keys must be 600, or SSH ignores the key.
To make connecting even quicker, add an alias to ~/.ssh/config on your host:
Host kali
HostName 192.168.1.45
User kali
IdentityFile ~/.ssh/id_ed25519
Now ssh kali is all you need.
Lab checklist
- VirtualBox installed, Kali VM imported and running
- Default password changed
- A network mode chosen deliberately (bridged at home, host-only for attack practice)
- SSH enabled, with key-based login from your host
- A snapshot taken now, so you can always return to this clean state
- Kali updated:
sudo apt update && sudo apt full-upgrade -y
What’s next
Your lab is ready. Next: Part 2: Linux Commands Every Ethical Hacker Must Know (+ Passwordless SSH). Later parts cover the types of hackers, the deep and dark web, and reconnaissance with real tools. If you’re new to security, read What is Cyber Security? first, and brush up your command line with Linux for DevOps: Zero to Hero. For the bigger picture of where these skills lead, see the DevSecOps Roadmap 2026.
Watch the full lab setup on my YouTube channel, Madhukar Reddy (@awsandevops).
