This project has been created as part of the 42 curriculum by hbani-at.
Build your first secure Linux server from scratch.
Born2beroot is one of the foundational system administration projects in the 42 Common Core. Unlike programming projects, this project focuses on understanding how a Linux operating system works internally, how to securely configure a server, and how to administer it following industry best practices.
Instead of writing code, you will install, configure, harden, and maintain a complete Linux server running inside a virtual machine. Along the way, you'll learn concepts used daily by Linux administrators, DevOps engineers, cloud engineers, cybersecurity professionals, and backend engineers.
| Item | Value |
|---|---|
| Project | Born2beroot |
| Curriculum | 42 Common Core |
| Category | System Administration |
| Language | Bash / Linux |
| Operating System | Debian (Stable) |
| Virtualization | VirtualBox |
| Security | AppArmor, UFW, SSH, sudo |
| Services | OpenSSH |
| Monitoring | Bash + cron |
| Subject Version | 4 |
- Project Overview
- Learning Objectives
- Why Does This Project Exist?
- Project Requirements
- Virtualization
- Hypervisors
- Virtualization Software
- Operating Systems
- Disk Partitioning
- Logical Volume Manager (LVM)
- Disk Encryption (LUKS)
- SSH
- Firewall (UFW)
- AppArmor
- Password Policy
- sudo Configuration
- Users and Groups
- Monitoring Script
- Cron
- Installation Guide
- Prerequisites
- Step 1: Create the Virtual Machine
- Step 2: Install Debian
- Step 3: Partitioning with LVM and Encryption
- Step 4: Post-Installation Setup
- Step 5: Configure sudo
- Step 6: Configure SSH
- Step 7: Configure UFW
- Step 8: Configure Password Policy
- Step 9: Create User and Assign Groups
- Step 10: Set Hostname
- Step 11: Set Up monitoring.sh
- Step 12: Configure Cron
- Step 13: Generate signature.txt
- Verification Checklist
- Evaluation Questions
- Useful Commands
- Troubleshooting
- Resources
Born2beroot introduces the fundamental concepts of Linux system administration by requiring the creation of a secure virtual server from scratch.
The project emphasizes security, system configuration, user management, networking, and automation, rather than software development.
The virtual machine must comply with a strict set of security requirements defined in the project subject, including:
- Installing a minimal Debian or Rocky Linux system
- Creating encrypted partitions using Logical Volume Manager (LVM)
- Configuring SSH to listen on port 4242
- Preventing direct root login through SSH
- Configuring a firewall (UFW for Debian)
- Enforcing a strong password policy
- Configuring sudo according to strict security rules
- Creating users and groups
- Writing a monitoring script that periodically displays system information
Although the project appears simple, it introduces many of the technologies used in production Linux servers around the world.
After completing this project, you should understand:
- Linux installation
- Virtualization and virtual machines
- Hypervisors (Type 1 vs Type 2)
- Disk partitioning
- Logical Volume Manager (LVM)
- LUKS disk encryption
- Symmetric vs asymmetric encryption
- Linux filesystem hierarchy
- User and group management
- Password management and PAM
- SSH protocol and configuration
- Firewalls and network ports
- Secure remote administration
- sudo and privilege escalation
- System services and systemd
- Bash scripting
- Cron and task scheduling
- System monitoring with
wall - Basic Linux security hardening
More importantly, this project teaches how Linux systems are administered in real-world environments rather than simply how to use Linux.
Most developers know how to write software.
Far fewer understand where that software actually runs.
Every web application, database, API, Docker container, Kubernetes cluster, or cloud deployment ultimately runs on an operating system.
Understanding how Linux works is therefore essential for:
- Software Engineers
- Backend Developers
- DevOps Engineers
- Cloud Engineers
- Site Reliability Engineers (SRE)
- Security Engineers
- System Administrators
Born2beroot provides the foundation upon which many later 42 projects—and many professional careers—are built.
Instead of treating Linux as a black box, this project encourages understanding what happens beneath the surface.
According to the official subject, the virtual machine must satisfy several mandatory requirements.
Choose one:
- Debian Stable (recommended)
- Rocky Linux
No graphical interface may be installed.
The server must use:
- encrypted partitions
- Logical Volume Manager (LVM)
The SSH server must:
- run on port 4242
- refuse direct root login
Configure:
- UFW (Debian) or firewalld (Rocky)
Only SSH on port 4242 should be accessible.
Implement:
- strong password policy
- sudo restrictions
- command logging
- password expiration
- password complexity rules
The system must contain:
- root
- your login user
Your user must belong to:
- sudo
- user42
Create a Bash script named monitoring.sh that periodically displays important system information using wall.
Optional bonus tasks:
- Set up a specific partition structure (see below)
- Set up a WordPress site with lighttpd, MariaDB, PHP
- Set up an additional useful service (NGINX and Apache2 excluded)
The subject bonus requires a structure similar to this:
sda
├── sda1 /boot (unencrypted, ~500 MB)
└── sda5 LUKS encrypted
└── LVM group
├── root → / (mandatory)
├── home → /home (mandatory)
├── var → /var (mandatory)
├── srv → /srv ← bonus
├── tmp → /tmp ← bonus
├── var--log → /var/log ← bonus
└── swap → [SWAP] (mandatory)
The bonus adds /srv, /tmp, and /var/log as separate logical volumes. Sizes are arbitrary — allocate what makes sense for your disk (e.g., 10.5 GB disk: 4 GB root, 2 GB home, 2 GB var, 1 GB srv, 500 MB tmp, 500 MB var-log, 500 MB swap).
The repository must also contain:
- README.md
- signature.txt
This section draws from IBM: What is Virtualization?
Imagine you own a very powerful computer.
Normally, that computer can run only one operating system at a time. If Windows is installed, then Windows controls all the hardware. If Debian is installed, then Debian controls all the hardware.
Virtualization changes this.
It allows a single physical computer to behave as if it were many independent computers, each running its own operating system.
Instead of buying multiple physical machines, we create Virtual Machines (VMs) that share the hardware of one computer.
Each virtual machine behaves like a completely separate computer, with its own:
- CPU
- RAM
- Hard disk
- Network card
- Operating System
- Users
- Files
- Services
Even though these components are virtual, the guest operating system cannot tell the difference.
Imagine an apartment building.
Apartment Building
┌─────────────────────────────────┐
│ Apartment 1 │ Apartment 2 │ Apartment 3 │
└─────────────────────────────────┘
▲ ▲ ▲
│ │ │
Separate families living independently
Everyone shares the same building. However, each apartment has its own furniture, its own electricity usage, its own rules, its own residents. No apartment can directly access another.
Virtualization works the same way.
Physical Computer
CPU
RAM
SSD
Network
│
▼
Hypervisor (VirtualBox)
│
┌──────────┼──────────┐
│ │ │
▼ ▼ ▼
Debian Ubuntu Windows
VM VM VM
One physical computer. Multiple isolated computers.
Before virtualization became popular, companies had to purchase one physical server for each application.
For example:
Database Server ─── Physical Machine #1
Web Server ─── Physical Machine #2
Mail Server ─── Physical Machine #3
Most of these machines were idle most of the time. CPU usage: 5%. RAM usage: 20%. Yet each required electricity, cooling, maintenance, hardware upgrades, and rack space.
This was extremely expensive.
Virtualization solved this problem by allowing many servers to share the same physical hardware. Today, almost every data center, cloud provider, and enterprise infrastructure relies on virtualization.
Instead of running one operating system per computer, multiple virtual machines share the available hardware. This significantly improves CPU, memory, and storage utilization.
Organizations save money by reducing the number of physical servers they need to purchase, power, cool, and maintain.
Every virtual machine is isolated. If one VM crashes, the others continue running. If malware infects one VM, the others remain unaffected.
A snapshot records the complete state of a virtual machine. If something goes wrong, you can restore the VM to an earlier state within seconds.
Note: The Born2beroot subject forbids having snapshots at the beginning of the evaluation, but they are extremely useful during development. Remove or delete them before your defense.
Need to experiment with a firewall? Try a risky kernel configuration? Install a new package? You can safely do so inside a virtual machine without affecting your main operating system.
A virtual machine is essentially a collection of files. You can move it to another computer and continue using it exactly where you left off.
A virtual machine emulates the essential hardware of a real computer.
| Component | Description |
|---|---|
| Virtual CPU (vCPU) | Executes instructions using the host CPU |
| Virtual RAM | Memory allocated from the host |
| Virtual Disk | A file that behaves like a hard drive |
| Virtual Network Card | Provides network connectivity |
| BIOS/UEFI | Starts the virtual machine during boot |
| Virtual Display | Used for graphical output (if installed) |
The operating system installed directly on the physical computer. Examples: Arch Linux, Debian, Windows, macOS. The host owns the actual hardware.
The operating system installed inside the virtual machine. For this project, the guest OS is Debian Stable. The guest believes it owns the hardware, but all hardware access is managed by the hypervisor.
Power On VM
│
▼
Virtual BIOS / UEFI
│
▼
Bootloader (GRUB)
│
▼
Linux Kernel
│
▼
Systemd
│
▼
Services Start: SSH, UFW, cron, AppArmor ...
│
▼
Login Prompt
The boot process is almost identical to that of a real server.
Unlike a physical computer, which uses an actual SSD or HDD, a virtual machine stores its disk inside a file.
For VirtualBox, this file usually has the extension .vdi.
| Extension | Hypervisor |
|---|---|
| .vdi | VirtualBox |
| .vmdk | VMware |
| .qcow2 | QEMU / UTM |
| .vhdx | Hyper-V |
To the guest operating system, this file appears to be a normal hard drive.
The Born2beroot project focuses on learning Linux system administration, not on installing Linux directly on your personal computer.
Virtualization offers several advantages in this context:
- Protects your host operating system from accidental damage
- Allows you to reinstall the server quickly if something goes wrong
- Provides an environment similar to real production servers
- Enables experimentation without risking your personal files
- Makes evaluation consistent across all students
- Virtualization allows multiple OSes to run on a single physical computer
- Each VM behaves like an independent computer
- A hypervisor manages access to the physical hardware
- VMs provide isolation, portability, and efficient resource utilization
This section draws from IBM: What is a Hypervisor? and VMware: Bare Metal Hypervisor
A hypervisor, also known as a Virtual Machine Monitor (VMM), is the software layer responsible for creating, running, and managing virtual machines.
Think of it as the manager between the physical hardware and the virtual machines. Without a hypervisor, virtualization would not be possible.
Virtual Machine
(Debian, Ubuntu, Windows)
│
▼
Hypervisor (VMM)
│
┌─────────────┼─────────────┐
│ │ │
CPU RAM Storage
│
▼
Physical Hardware
The hypervisor is responsible for:
- Creating virtual machines
- Allocating CPU cores
- Allocating RAM
- Managing virtual disks
- Managing networking
- Isolating VMs from one another
- Scheduling access to hardware resources
Imagine installing Debian, Ubuntu, and Windows directly on the same hardware at the same time. Each OS would try to control the CPU, manage memory, access the disk, and configure network devices. Chaos would result.
A hypervisor solves this by acting as an intermediary. Instead of accessing hardware directly, each guest OS communicates with the hypervisor, which safely coordinates access to physical resources.
A Type 1 Hypervisor runs directly on the physical hardware. There is no traditional OS between the hardware and the hypervisor.
Applications
Virtual Machines
──────────────
Type 1 Hypervisor
──────────────
CPU • RAM • Disk • Network
──────────────
Physical Hardware
Since the hypervisor has direct access to the hardware, it provides better performance, lower latency, better scalability, and improved security.
- Near-native performance
- Efficient resource management
- Excellent isolation
- Designed for production environments
- More complex to configure
- Usually intended for servers
- Requires dedicated hardware
- VMware ESXi
- Microsoft Hyper-V Server
- Xen
- Citrix Hypervisor
A Type 2 Hypervisor runs on top of an existing operating system.
Virtual Machine
──────────────
VirtualBox
──────────────
Host OS (Windows / Linux / macOS)
──────────────
Physical Hardware
Instead of communicating directly with the hardware, the hypervisor asks the host OS to perform hardware operations. Every request passes through the host OS, creating a small performance overhead.
- Easy to install
- Beginner friendly
- Great for development and testing
- Convenient snapshots
- Slightly lower performance
- Higher resource usage
- Depends on host OS stability
This is exactly why 42 uses VirtualBox for Born2beroot.
| Feature | Type 1 | Type 2 |
|---|---|---|
| Runs directly on hardware | Yes | No |
| Requires host OS | No | Yes |
| Performance | Excellent | Very Good |
| Complexity | Higher | Lower |
| Common Usage | Data Centers | Personal Computers |
| Best For | Production | Development & Learning |
KVM (Kernel-based Virtual Machine) is an interesting case. Technically, KVM is built directly into the Linux kernel. When enabled, the Linux kernel itself becomes a hypervisor.
Virtual Machines
│
▼
KVM
│
▼
Linux Kernel
│
▼
Hardware
Although KVM runs within Linux, it operates at the kernel level and has direct access to hardware virtualization features (Intel VT-x or AMD-V). Because of this architecture, KVM delivers performance very close to traditional Type 1 hypervisors.
Many professionals describe KVM as "Type 1-like" because of its efficiency. Large cloud providers like OpenStack commonly rely on KVM.
Source: Red Hat: What is KVM?
| Hypervisor | Type | Common Usage |
|---|---|---|
| VirtualBox | Type 2 | Learning, Development |
| VMware Workstation | Type 2 | Development |
| VMware ESXi | Type 1 | Enterprise Data Centers |
| Hyper-V | Type 1 | Windows Server Environments |
| Xen | Type 1 | Cloud Infrastructure |
| KVM | Kernel-Based | Linux Servers & Cloud Platforms |
Modern CPUs include hardware features specifically designed for virtualization. Intel calls this Intel VT-x; AMD calls it AMD-V. Without these technologies, virtualization would be much slower because the hypervisor would need to emulate privileged CPU instructions in software. Hardware-assisted virtualization allows guest OSes to execute most instructions directly on the processor while still remaining isolated.
To complete Born2beroot, we need software capable of creating and managing virtual machines. The 42 subject recommends:
- VirtualBox (most platforms)
- UTM (Apple Silicon Macs)
VirtualBox is a free and open-source virtualization software developed by Oracle. It is a Type 2 (Hosted) Hypervisor.
+----------------------------------+
| Debian VM |
+----------------------------------+
| VirtualBox |
+----------------------------------+
| Windows / Linux / macOS Host |
+----------------------------------+
| Physical Hardware |
+----------------------------------+
- Multiple OS support: Run several OSes simultaneously
- Virtual hardware: CPU, RAM, disk, network, USB, audio
- Snapshots: Save and restore VM state instantly
- Shared clipboard: Copy/paste between host and guest
- Shared folders: Expose host directories inside the guest
- Networking modes: NAT, Bridged, Host-Only, Internal Network
UTM is a virtualization application designed primarily for macOS. It is especially popular on Apple Silicon (M1, M2, M3) because it provides excellent support for ARM-based systems.
Unlike VirtualBox, UTM is built on top of QEMU, one of the most powerful open-source virtualization projects.
Debian VM
│
▼
UTM
│
▼
QEMU
│
▼
Apple macOS
│
▼
Apple Silicon Hardware
| Feature | Virtualization | Emulation |
|---|---|---|
| CPU Architecture | Same as host | Different from host |
| Performance | Near-native | Significantly slower |
| Translation | Minimal (hardware-assisted) | Full instruction translation |
| Feature | VirtualBox | UTM |
|---|---|---|
| Platform | Windows, Linux, macOS | macOS |
| Hypervisor Type | Type 2 | QEMU-based |
| Apple Silicon Support | Limited | Excellent |
| x86 Virtualization | Excellent | Excellent |
| Ease of Use | Excellent | Excellent |
Both applications are capable of completing Born2beroot successfully. The choice depends mainly on the host operating system.
An Operating System (OS) is the software that manages a computer's hardware and provides services for applications. It acts as the bridge between the user (or applications) and the physical hardware.
An OS is responsible for: managing processes, memory, storage, users and permissions, networking, filesystems, security, CPU scheduling, and hardware drivers.
User
│
Applications (SSH, Bash, etc.)
│
Operating System
│
CPU • RAM • Disk • Network • GPU
Linux is not an operating system by itself. Linux is a kernel. The kernel is the core component that communicates with hardware, manages memory, schedules processes, handles filesystems, and provides system calls.
A complete Linux operating system consists of:
Applications
│
▼
System Utilities
│
▼
GNU Tools
│
▼
Linux Kernel
│
▼
Hardware
Because the Linux kernel is open source, anyone can build an OS around it. These are called Linux distributions.
A Linux distribution (or distro) is a complete OS built around the Linux kernel. It usually includes:
- Linux kernel
- Package manager
- Installer
- GNU utilities
- Shell
- Security tools
- Repositories
| Distribution | Primary Use |
|---|---|
| Debian | Stability |
| Ubuntu | Desktop & Server |
| Fedora | Latest Features |
| Rocky Linux | Enterprise |
| Arch Linux | Rolling Release |
The Born2beroot subject allows Debian and Rocky Linux because they represent two of the most influential Linux families:
Linux
┌────────┴────────┐
Debian Family Red Hat Family
│ │
Debian RHEL
│ │
Ubuntu Rocky Linux
AlmaLinux
Fedora
Learning either one provides a strong foundation for Linux system administration.
Debian is one of the oldest and most respected Linux distributions. Created in 1993 by Ian Murdock, it is developed by a worldwide community of volunteers.
Its primary goals are: stability, reliability, security, and free software. Debian values stability over having the newest software versions. Many servers run Debian for years without major issues.
- Extensive documentation
- Huge community support
- Stable package repositories
- Predictable behavior
- Excellent VirtualBox compatibility
- Beginner-friendly package management
- Large number of tutorials
Rocky Linux is an enterprise Linux distribution released in 2021, created after Red Hat changed the direction of CentOS. It aims to be 100% compatible with Red Hat Enterprise Linux (RHEL).
- Enterprise stability
- Long-term support
- RHEL compatibility
- Excellent security
- Professional server ecosystem
| Feature | Debian | Rocky Linux |
|---|---|---|
| Family | Debian | Red Hat |
| Package Manager | APT | DNF |
| Package Format | .deb | .rpm |
| Primary Goal | Stability | Enterprise Stability |
| Community | Large | Growing |
| Enterprise Adoption | High | Very High |
| Beginner Friendly | Excellent | Good |
A package manager installs, updates, removes, and manages software. Instead of downloading programs manually, Linux distributions install software from trusted repositories.
| Distribution | Package Manager |
|---|---|
| Debian / Ubuntu | apt |
| Rocky Linux / Fedora | dnf |
| Arch Linux | pacman |
The Born2beroot evaluation frequently includes questions about the difference between apt and aptitude.
apt is the modern command-line package manager used by Debian.
sudo apt update
sudo apt upgrade
sudo apt install nginxAdvantages: Fast, simple, officially recommended, installed by default, used in most documentation.
aptitude is an alternative package manager with more advanced dependency resolution than apt. It also includes an interactive text-based interface.
sudo aptitude install nginxAdvantages: Better dependency conflict resolution, interactive interface, advanced package searching.
Disadvantages: Not installed by default, less commonly used today.
For Born2beroot, apt is preferred because it is installed by default and is the standard tool in Debian documentation. aptitude remains a powerful tool, but apt has improved significantly over the years.
The project tests whether you understand that Linux provides multiple tools for the same task, each with its own design goals. Being able to explain why you chose apt demonstrates deeper understanding than simply knowing the command syntax.
Source: Packagecloud: apt vs aptitude
A disk is a storage device used to permanently store data. In a physical computer, this could be an HDD, SSD, or NVMe SSD. Inside a virtual machine, the "disk" is actually a file created by the hypervisor (.vdi for VirtualBox).
Host Computer → VirtualBox → Debian.vdi → Inside VM: /dev/sda
Linux has no idea that the disk is virtual.
Imagine buying a huge warehouse. You could throw everything into one giant room, but finding anything would quickly become a nightmare. Instead, warehouses create separate sections.
A disk partition works the same way. Instead of one huge storage area, the disk is divided into multiple independent sections. Each partition can have its own filesystem, purpose, permissions, and mount point.
This organization improves security, reliability, maintenance, and recovery.
Before partitions can exist, the disk needs a partition table that describes where each partition begins and ends, its size, and its type.
The older partitioning scheme.
| Pros | Cons |
|---|---|
| Widely supported | Max disk size ~2 TB |
| Simple | Max 4 primary partitions |
| Compatible with BIOS | Older design |
The modern partition table.
| Pros |
|---|
| Supports disks >2 TB |
| Supports many more partitions |
| Better reliability |
| Redundant partition tables |
This topic frequently appears during the Born2beroot evaluation.
A primary partition exists directly in the partition table. MBR allows only four primary partitions.
An extended partition is a special partition that acts as a container for logical partitions.
A logical partition exists inside an extended partition. Functionally, it behaves almost the same as a primary partition.
| Feature | Primary | Logical |
|---|---|---|
| Exists directly in partition table | Yes | No |
| Can boot an OS | Yes | Usually Yes |
| MBR Limit | Max 4 | Many |
| Location | Directly on disk | Inside extended partition |
With GPT, this distinction is largely obsolete because GPT allows many partitions without needing logical partitions.
Source: EaseUS: Logical vs Primary Partition
A partition by itself is just empty space. Before Linux can store files on it, the partition must be formatted with a filesystem.
The default filesystem for most Linux distributions. Stable, reliable, fast, with journaling support. Born2beroot commonly uses ext4.
Swap is not a traditional filesystem. It is disk space used as virtual memory. When RAM becomes full, the OS moves inactive pages to swap.
Linux does not assign drive letters like Windows. Instead, every partition is attached to a directory called a mount point.
Partition → Format → Filesystem → Mount → Directory
Example:
/dev/sda1 → ext4 → mounted at /
/dev/sda2 → ext4 → mounted at /home
/dev/sda3 → ext4 → mounted at /var
/dev/sda4 → swap
| Partition | Purpose |
|---|---|
/ |
Root filesystem (OS) |
/boot |
Bootloader and kernel files |
/home |
User home directories |
swap |
Virtual memory |
/var |
Logs, caches, variable data |
By isolating these directories, a problem affecting one partition is less likely to impact the rest of the system.
This section draws from Wikipedia: LVM and Linux Handbook: LVM Guide
Logical Volume Manager (LVM) is a storage management layer that sits between the physical disk partitions and the filesystem.
Instead of creating fixed partitions directly on the disk, LVM introduces an abstraction layer that allows storage to be managed much more flexibly.
Think of LVM as a storage manager. Instead of saying "this partition is permanently 10 GB," you say "create a storage pool, then allocate space from that pool whenever it's needed."
Traditional partitioning has one major problem: partitions have fixed sizes.
Imagine you create:
/ 10 GB
/home 5 GB
/var 5 GB
Months later, /home is 100% full but /var is only 10% used. Although plenty of free space exists on the disk, /home cannot use it because its partition size was fixed during installation.
LVM was designed to solve exactly this problem.
LVM is built around three concepts:
The lowest layer. Represents a physical storage device (entire disk, partition, or block device) that LVM can use.
/dev/sda2
│
▼
Physical Volume (PV)
A storage pool created by combining one or more Physical Volumes.
PV1 = 20 GB
PV2 = 30 GB
PV3 = 50 GB
│
▼
VG = 100 GB
Created from the free space inside a Volume Group.
Volume Group (100 GB)
│
├── Root LV (30 GB) → ext4 → /
├── Home LV (20 GB) → ext4 → /home
├── Var LV (15 GB) → ext4 → /var
└── Swap LV (8 GB) → swap
To Linux, a Logical Volume looks exactly like a normal partition:
/dev/mapper/debian--vg-root
/dev/mapper/debian--vg-home
Physical Disk
│
▼
Partition
│
▼
Physical Volume
│
▼
Volume Group
│
▼
Logical Volume
│
▼
Filesystem (ext4)
│
▼
Mount Point (/home, /var, /)
A typical Debian installation for Born2beroot:
Virtual Disk
│
▼
Physical Volume
│
▼
Volume Group: debian-vg
│
├── root → /
├── home → /home
├── var → /var
└── swap → swap
| Feature | Traditional | LVM |
|---|---|---|
| Fixed Sizes | Yes | No |
| Easy Resizing | Difficult | Easy |
| Multiple Disks | Limited | Supported |
| Storage Pool | No | Yes |
| Snapshots | No | Yes |
sudo pvs # View Physical Volumes
sudo vgs # View Volume Groups
sudo lvs # View Logical Volumes
sudo lvdisplay # Detailed LV info
sudo vgdisplay # Detailed VG info
sudo pvdisplay # Detailed PV infoEncryption is the process of converting data into a coded form that can only be read by someone who has the correct decryption key. If an attacker gains physical access to the disk, encrypted data remains unreadable without the passphrase.
| Feature | Symmetric | Asymmetric |
|---|---|---|
| Keys | One shared key | Public + Private key pair |
| Speed | Fast | Slow |
| Usage | Encrypting data at rest | Key exchange, SSH, SSL/TLS |
| Example | AES, ChaCha20 | RSA, ECDSA |
In LUKS disk encryption, symmetric encryption is used. The passphrase you enter at boot is used to derive the symmetric key that decrypts the data.
Source: Medium: Symmetric and Asymmetric Encryption
LUKS (Linux Unified Key Setup) is the standard for Linux disk encryption. It provides a platform-independent way to manage encryption keys and protect data at rest.
LUKS is not the encryption algorithm itself. It is a key management standard that sits on top of encryption algorithms like AES. It handles:
- Storing encrypted keys on disk
- Allowing multiple passphrases (up to 8)
- Providing a header with encryption metadata
- Making encrypted disks portable between systems
Disk Partition
│
▼
LUKS Header (encryption metadata, key slots)
│
▼
Encrypted Data (AES encrypted)
│
▼
Upon boot: Enter passphrase → LUKS decrypts key → Filesystem accessible
When the system boots, you are prompted for a passphrase. LUKS uses this passphrase to decrypt the master key, which then decrypts the data. Without the correct passphrase, the data appears as random noise.
+---------------------------+
| LUKS phdr (header) |
| - Magic: "LUKS" |
| - Cipher: aes-xts-plain64 |
| - Hash: sha256 |
| - Key size: 512 bits |
+---------------------------+
| Key Slot 0 (active) |
| Key Slot 1 (free) |
| Key Slot 2-7 (free) |
+---------------------------+
| Encrypted Data |
| (ext4 filesystem) |
+---------------------------+
LUKS supports up to 8 key slots. Each slot can hold a copy of the master encryption key, encrypted with a different passphrase. This allows:
- Multiple users to have different passphrases
- Adding backup passphrases
- Revoking a passphrase by removing its key slot
The subject requires at least 2 encrypted partitions using LVM. This is a fundamental security practice:
- Physical theft protection: If someone steals the VM disk file, they cannot read the data without the passphrase
- Data confidentiality: Even if the disk is moved to another system, data remains protected
- Compliance requirement: Encrypted storage is a standard requirement in enterprise and regulated environments
- Real-world practice: Production servers almost always use disk encryption
sudo dmsetup ls # List device mapper targets (includes LUKS)
sudo cryptsetup status <name> # Check LUKS device status
lsblk # Check partition layout
sudo blkid # Check filesystem types and UUIDsExample output of lsblk with LUKS:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 32G 0 disk
├─sda1 8:1 0 487M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 31.5G 0 part
└─sda5_crypt 254:0 0 31.5G 0 crypt
├─debian--vg-root 254:1 0 10G 0 lvm /
├─debian--vg-home 254:2 0 5G 0 lvm /home
├─debian--vg-var 254:3 0 5G 0 lvm /var
└─debian--vg-swap 254:4 0 2G 0 lvm [SWAP]
This section draws from DigitalOcean: Understanding SSH Encryption, SSH.com: sshd, and the user's SSH notes.
SSH (Secure Shell) is a cryptographic network protocol for operating network services securely over an unsecured network. It provides encrypted communication between a client and a server.
SSH ensures:
- Confidentiality: Encrypts data between client and server
- Integrity: Verifies data hasn't been tampered with
- Authentication: Confirms identities of clients and servers
In Born2beroot, SSH is the only way to access the server remotely. The subject requires SSH to be running on port 4242 and must refuse direct root login.
SSH uses a combination of symmetric encryption (for the session), asymmetric encryption (for key exchange), and hashing (for integrity).
Client Server
│ │
├── TCP Connection (port 22) ──►│
│◄── Server Host Key ───────────┤
│── Key Exchange Init ────────►│
│◄── Diffie-Hellman Reply ─────┤
│ │
│ [Symmetric Session Key │
│ Established Securely] │
│ │
│── SSH User Auth Request ────►│
│◄── Auth Challenge ────────────┤
│── Auth Response ────────────►│
│◄── Auth Success ──────────────┤
│ │
│ [Encrypted Session Begins] │
│ │
-
TCP Handshake: Client connects to server on port 22 (or 4242 in our case)
-
Server Identification: Server sends its host key. Client checks against
~/.ssh/known_hoststo verify it's the expected server (prevents man-in-the-middle attacks) -
Key Exchange (Diffie-Hellman): Client and server generate a shared symmetric session key using asymmetric encryption. This key will encrypt all further communication
-
User Authentication: The client authenticates using either:
- Password authentication: Password is sent through the encrypted tunnel
- Public key authentication: Client signs a challenge with its private key
-
Session Established: An encrypted shell session begins
Each SSH server has a unique host key pair (typically RSA, ECDSA, or Ed25519). When a client connects, the server presents its public key. The client checks this against its known_hosts file.
If keys do not match, a warning is issued, preventing man-in-the-middle attacks.
~/.ssh/known_hosts
/etc/ssh/ssh_known_hosts
SSH uses three types of encryption:
| Type | Role | Algorithm Example |
|---|---|---|
| Symmetric | Encrypts the session data | AES, ChaCha20 |
| Asymmetric | Key exchange, host authentication | RSA, ECDSA, Ed25519 |
| Hashing | Integrity checking | HMAC-SHA256 |
Source: DigitalOcean: Understanding the SSH Encryption and Connection Process
The OpenSSH server configuration file is:
/etc/ssh/sshd_config
| File/Purpose |
|---|
/etc/ssh/sshd_config — SSH server configuration |
/etc/ssh/ssh_config — SSH client configuration |
/etc/ssh/ssh_host_* — Host key pairs |
~/.ssh/authorized_keys — Public keys for key-based auth |
~/.ssh/known_hosts — Known host keys |
~/.ssh/id_rsa — User's private key |
~/.ssh/id_rsa.pub — User's public key |
The subject requires SSH to run on port 4242 instead of the default port 22.
# Edit /etc/ssh/sshd_config
# Change this line:
# Port 22
# To:
Port 4242After making changes, restart the service:
sudo systemctl restart sshWhy change the port? While security by obscurity is not true security, changing the default port reduces automated brute-force attacks that scan only port 22. Combined with a strong password policy and key-based authentication, this improves security.
How to connect:
ssh your_login@localhost -p 4242The subject requires that direct root login via SSH is disabled.
# Edit /etc/ssh/sshd_config
PermitRootLogin noWhy disable root login?
- The root username exists on every Linux system. An attacker only needs to guess the password, not the username
- Root has unrestricted privileges. Compromise leads to maximum damage
- Auditing is harder when multiple admins share the root account
- Forces users to log in as a regular user and escalate via sudo, providing accountability
On modern systems, the default may be prohibit-password, which allows key-based root login but not password-based.
sudo systemctl restart sshSSH supports authentication using public/private key pairs instead of passwords.
ssh-keygen -t ed25519
# or
ssh-keygen -t rsa -b 4096ssh-copy-id -i ~/.ssh/id_ed25519.pub your_login@localhost -p 4242Client Server
│ │
│── Request auth (public key) ►│
│◄── Challenge encrypted with │
│ user's public key │
│ │
│── Decrypt challenge using │
│ private key │
│── Send proof back ──────────►│
│◄── Access granted ───────────┤
# Check SSH service status
sudo systemctl status ssh
# Verify listening port
ss -tlnp | grep 4242
# Check SSH config for root login
sudo grep PermitRootLogin /etc/ssh/sshd_config
# Test connection
ssh your_login@localhost -p 4242Expected results:
- SSH service is active (running)
- Listening on port 4242
- Root login is denied
- Connection works as a regular user
A firewall is a network security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules. It establishes a barrier between a trusted internal network and untrusted external networks.
UFW (Uncomplicated Firewall) is a user-friendly frontend for managing iptables firewall rules on Linux. It is the default firewall tool for Debian and Ubuntu systems.
UFW simplifies iptables commands into easy-to-understand syntax:
ufw allow 4242instead of the equivalent iptables command:
iptables -A INPUT -p tcp --dport 4242 -j ACCEPT- Reduces attack surface: Only explicitly allowed ports are accessible
- Blocks unwanted traffic: Prevents unauthorized access attempts
- Industry standard: Every production server has a firewall
- Subject requirement: The firewall must block all ports except 4242
Without a firewall, every running service is exposed to the network. A misconfigured or vulnerable service could be exploited.
Before adding rules, set the default policy:
sudo ufw default deny incoming
sudo ufw default allow outgoingThis ensures all incoming traffic is blocked by default unless explicitly allowed.
sudo ufw allow 4242sudo ufw enablesudo ufw status numberedExpected output:
Status: active
To Action From
-- ------ ----
4242 ALLOW Anywhere
4242 (v6) ALLOW Anywhere (v6)
sudo ufw status # Show current rules
sudo ufw status numbered # Show rules with numbers
sudo ufw delete NUM # Delete rule by number
sudo ufw disable # Disable firewall
sudo ufw reload # Reload firewall# Check if UFW is active
sudo ufw status
# Verify only port 4242 is open
ss -tlnp
# Check UFW rules are persistent
sudo ufw show addedSource: DigitalOcean: UFW Essentials
AppArmor (Application Armor) is a Linux security module that provides Mandatory Access Control (MAC). It allows the system administrator to restrict programs' capabilities on a per-program basis.
AppArmor confines programs to a limited set of resources (files, network, capabilities) rather than allowing full system access.
AppArmor uses security profiles loaded into the kernel to restrict what a program can do. Profiles can run in two modes:
| Mode | Description |
|---|---|
| Enforce | Policy is enforced. Violations are logged and blocked |
| Complain | Policy is not enforced. Violations are logged but allowed |
AppArmor profiles are stored in:
/etc/apparmor.d/
Example profile for a program:
/etc/apparmor.d/usr.sbin.sshd
sudo aa-statusExample output:
apparmor module is loaded.
14 profiles are loaded.
14 profiles are in enforce mode.
/usr/bin/man
/usr/sbin/sshd
...
0 profiles are in complain mode.
sudo aa-status # Show AppArmor status
sudo aa-enforce <path> # Set profile to enforce mode
sudo aa-complain <path> # Set profile to complain mode
sudo apparmor_parser -r <profile> # Reload a profileFor Debian, the subject requires AppArmor. For Rocky Linux, the subject requires SELinux.
| Feature | AppArmor | SELinux |
|---|---|---|
| Type | MAC (Mandatory Access Control) | MAC |
| Default on | Debian, Ubuntu | RHEL, Rocky, Fedora |
| Configuration | Path-based profiles | Label-based policies |
| Ease of Use | Simpler, more beginner-friendly | More complex |
| Granularity | Moderate | Very high |
| Profile Language | Easier to write | More complex rules |
AppArmor is simpler to configure than SELinux while still providing strong security. It is the default MAC system for Debian and is sufficient for the project requirements.
The subject requires AppArmor to be running at startup. This ensures:
- Programs are confined to their required resources
- Even if a service is compromised, damage is limited
- Students learn about Mandatory Access Control concepts
- Security best practices are reinforced
# Check if AppArmor is loaded and running
sudo aa-status
# Alternatively
sudo cat /sys/module/apparmor/parameters/enabled
# Output: Y
# Check AppArmor service
sudo systemctl status apparmorA password policy is a set of rules designed to enhance computer security by requiring users to create strong passwords and manage them properly. It typically covers password length, complexity, expiration, and history.
According to the Born2beroot subject:
| Requirement | Value |
|---|---|
| Password expiration | Every 30 days |
| Min days before password change | 2 days |
| Warning before expiration | 7 days |
| Minimum password length | 10 characters |
| Must contain | Uppercase, lowercase, number |
| Max consecutive identical chars | 3 |
| Must not contain username | Yes |
| Root password follows policy | Yes |
Password aging settings are configured in /etc/login.defs.
sudo nano /etc/login.defsSet the following values (these apply to new users):
PASS_MAX_DAYS 30
PASS_MIN_DAYS 2
PASS_WARN_AGE 7
| Setting | Purpose | Subject Value |
|---|---|---|
PASS_MAX_DAYS |
Max days a password is valid | 30 |
PASS_MIN_DAYS |
Min days before password can be changed | 2 |
PASS_WARN_AGE |
Days before expiration to warn user | 7 |
The settings in /etc/login.defs only apply to newly created users. For existing users, use chage:
sudo chage -M 30 -m 2 -W 7 your_login
sudo chage -M 30 -m 2 -W 7 rootVerify with:
sudo chage -l your_login
sudo chage -l rootExample output:
Last password change : May 01, 2024
Password expires : May 31, 2024
Password inactive : never
Account expires : never
Minimum number of days between password change : 2
Maximum number of days between password change : 30
Number of days of warning before password expires : 7
Password complexity is managed by PAM (Pluggable Authentication Modules). PAM is a flexible framework for authentication on Linux systems.
For Debian, the pam_pwquality module enforces password quality rules:
sudo apt update
sudo apt install libpam-pwqualityEdit /etc/pam.d/common-password:
sudo nano /etc/pam.d/common-passwordFind the line containing pam_pwquality.so and modify it:
password requisite pam_pwquality.so retry=3 minlen=10 ucredit=-1 lcredit=-1 dcredit=-1 maxrepeat=3 reject_username difok=7
⚠️ difok=7 and root: The subject says "The following rule does not apply to the root password: The password must have at least 7 characters that are not part of the former password. Of course, your root password has to comply with this policy." This meansdifok=7explicitly does NOT apply to root. PAM'spam_pwqualityexempts root by default — so we omitenforce_for_root. This means no PAM complexity rules apply to root. To still enforce aging rules on root, usechage(covered above). If you prefer simplicity, addenforce_for_root(most evaluators accept it), but know the subject carves outdifokfor root.
| Parameter | Meaning | Subject Value |
|---|---|---|
retry=3 |
Allow 3 attempts before failure | 3 |
minlen=10 |
Minimum password length | 10 |
ucredit=-1 |
At least 1 uppercase letter | 1 |
lcredit=-1 |
At least 1 lowercase letter | 1 |
dcredit=-1 |
At least 1 digit | 1 |
maxrepeat=3 |
Max 3 consecutive identical chars | 3 |
reject_username |
Password must not contain username | Yes |
difok=7 |
At least 7 chars different from old password | 7 |
| (no enforce_for_root) | difok=7 does not apply to root per subject | Not set |
PAM (Pluggable Authentication Modules) is a framework that allows system administrators to configure authentication methods independently of applications. Instead of each application implementing its own authentication, PAM provides a unified API.
Application (login, sshd, passwd)
│
▼
┌──────────────────────────┐
│ PAM Library │
│ (libpam.so) │
│ │
│ Reads /etc/pam.d/<app> │
└──────┬───────────────────┘
│
▼
┌──────────────────────────┐
│ PAM Modules │
│ │
│ pam_unix (auth) │
│ pam_pwquality (quality) │
│ pam_limits (limits) │
│ pam_env (env) │
└──────────────────────────┘
PAM modules are stacked. The order matters:
required— must pass for auth to succeed; other modules still runrequisite— fails immediately if this module failssufficient— skips remaining modules on success
Located in /etc/pam.d/:
/etc/pam.d/
├── common-password # Password rules
├── common-auth # Authentication rules
├── common-account # Account management
├── common-session # Session management
├── login # Login authentication
└── sshd # SSH authentication
# Check password aging for a user
sudo chage -l your_login
# Check global password defaults
grep PASS_MAX /etc/login.defs
grep PASS_MIN /etc/login.defs
grep PASS_WARN /etc/login.defs
# Check PAM password configuration
grep pam_pwquality /etc/pam.d/common-passwordSource: OSTechNix: Set Password Policies in Linux
sudo (Superuser DO) allows a permitted user to execute a command as the superuser or another user, while being logged for accountability.
| Feature | su | sudo |
|---|---|---|
| Requires root password | Yes | No (uses user's password) |
| Logs commands | No | Yes |
| Granular permissions | No | Yes |
| Keeps user environment | No | Yes |
The subject requires:
| Requirement | Value |
|---|---|
| Max authentication attempts | 3 |
| Custom error message | Yes |
| Log all actions (input + output) | Yes, in /var/log/sudo/ |
| TTY mode enabled | Yes |
| Restricted PATH | Yes |
Create a custom sudo configuration file:
sudo visudo -f /etc/sudoers.d/sudoconfigAdd the following rules:
Defaults passwd_tries=3
Defaults badpass_message="Incorrect password. Please try again."
Defaults log_input, log_output
Defaults iolog_dir=/var/log/sudo
Defaults requiretty
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
| Directive | Purpose |
|---|---|
passwd_tries=3 |
Max 3 wrong password attempts before sudo fails |
badpass_message="..." |
Custom message shown on wrong password |
log_input |
Log all input typed during sudo sessions |
log_output |
Log all output displayed during sudo sessions |
iolog_dir=/var/log/sudo |
Directory for sudo I/O logs |
requiretty |
sudo can only be run from a terminal (TTY) |
secure_path=... |
Restricted PATH for sudo commands |
# Check sudo configuration
sudo -l
# Check that the config file is valid
visudo -c -f /etc/sudoers.d/sudoconfigAll sudo actions are logged. Input logs capture what the user typed; output logs capture what was displayed.
# View sudo log directory
sudo ls -la /var/log/sudo/
# Read sudo logs (use sudoreplay for I/O logs)
sudo sudoreplay -l- Accountability: Every privileged action is traced to a specific user
- Auditing: Security teams can review who did what and when
- Forensics: In case of a breach, logs help determine the attack vector
- Subject requirement: All sudo input and output must be archived
A user account provides security boundaries, a unique identifier (UID), and ownership of processes and files.
| Type | Description |
|---|---|
| Superuser (root) | UID 0, full system access |
| System users | Used by services/daemons |
| Regular users | Used for daily activities |
Stores user account metadata:
username:x:UID:GID:comment:home_directory:shell
| Field | Description |
|---|---|
username |
Login name |
x |
Password placeholder (hash in /etc/shadow) |
UID |
User ID |
GID |
Primary Group ID |
comment |
Full name / description |
home_directory |
User's home directory |
shell |
Default login shell |
Stores encrypted password hashes and aging information:
username:$algorithm$salt$hash:last_change:min:max:warn:inactive:expire
| Field | Description |
|---|---|
$algorithm$ |
Hash algorithm ($y$ = yescrypt, $6$ = SHA-512) |
salt |
Random salt value |
hash |
Cryptographic hash of password |
last_change |
Days since epoch of last password change |
min |
Minimum days before password change |
max |
Maximum days before password change |
warn |
Warning days before expiration |
A group is a collection of users to share access to files or resources. Identified by GID, stored in /etc/group.
group_name:x:GID:user1,user2,user3
| Type | Description |
|---|---|
| Primary group | Defined in /etc/passwd, owns user's files |
| Supplementary group | Listed in /etc/group, for extra access |
The Born2beroot subject requires:
- A user with your login as the username
- The user must belong to sudo and user42 groups
- During evaluation, you must create a new user and assign it to a group
sudo useradd -m username
sudo passwd usernamesudo usermod -aG groupname username # Add to supplementary group
sudo usermod -s /bin/bash username # Change shellsudo userdel username # Delete user
sudo userdel -r username # Delete user + home directorysudo groupadd groupnamesudo usermod -aG groupname usernamesudo gpasswd -d username groupnameid username # Show UID, GID, groups
groups username # Show groups for a user
getent group groupname # Show group members| File | Purpose |
|---|---|
/etc/passwd |
User account information |
/etc/shadow |
Encrypted password hashes |
/etc/group |
Group database |
/etc/sudoers |
sudo configuration |
/etc/login.defs |
Password aging and user creation defaults |
/etc/hostname |
Machine hostname |
/etc/hosts |
Local hostname resolution |
/etc/ssh/sshd_config |
SSH server configuration |
/etc/pam.d/common-password |
PAM password rules |
The monitoring script is a Bash script that displays system information on all terminals every 10 minutes. It is executed at server startup and runs periodically via cron.
The script must display the following information:
- Architecture — OS and kernel version
- Physical processors — Number of physical CPUs
- Virtual processors — Number of virtual CPUs (vCPUs)
- RAM usage — Current available RAM and utilization percentage
- Disk usage — Current available storage and utilization percentage
- CPU load — Current utilization rate of processors
- Last boot — Date and time of the last reboot
- LVM status — Whether LVM is active
- Active connections — Number of active TCP connections
- User log — Number of users on the server
- Network — IPv4 address and MAC address
- Sudo count — Number of commands executed with sudo
arch=$(uname -a)uname -a prints all system information: kernel name, hostname, kernel release, kernel version, machine hardware, and OS.
pcpu=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)Each physical CPU has a unique physical id in /proc/cpuinfo. Sorting unique IDs and counting them gives the number of physical processors.
vcpu=$(grep "^processor" /proc/cpuinfo | wc -l)Each logical processor (including hyperthreading) is listed as processor in /proc/cpuinfo.
ram_total=$(free --mega | awk '$1 == "Mem:" {print $2}')
ram_used=$(free --mega | awk '$1 == "Mem:" {print $3}')
ram_percent=$(free --mega | awk '$1 == "Mem:" {printf "%.2f", $3/$2*100}')free --mega displays memory in megabytes. awk extracts total and used values.
disk_total=$(df -BG --total | grep "total" | awk '{print $2}')
disk_used=$(df -BG --total | grep "total" | awk '{print $3}')
disk_percent=$(df -B1 --total | grep "total" | awk '{printf "%.2f", $3/$2*100}')df displays filesystem disk usage. -BG shows values in gigabytes. The --total line sums all filesystems.
cpu_load=$(top -bn1 | grep "^%Cpu" | awk '{print $2}')top -bn1 runs one iteration of top in batch mode. The %Cpu line shows CPU utilization. Field 2 is the user-space CPU percentage.
last_boot=$(who -b | awk '{print $3 " " $4}')who -b shows the last system boot time.
lvm_active=$(lsblk | grep "lvm" | wc -l)
lvm_status=$(if [ $lvm_active -eq 0 ]; then echo "no"; else echo "yes"; fi)lsblk lists block devices. If any device uses LVM, the output will contain "lvm".
tcp_connections=$(ss -tln | wc -l)ss -tln shows listening TCP sockets. The count gives active connections.
user_log=$(who | wc -l)who lists currently logged-in users.
ipv4=$(hostname -I)
mac=$(ip link show | grep "ether" | awk '{print $2}')hostname -I shows the IPv4 address. ip link show shows network interfaces; the ether line contains the MAC address.
sudo_count=$(grep -c "sudo" /var/log/sudo/seq)Counts entries in the sudo log sequence file. Alternatively:
sudo_count=$(journalctl | grep -c "sudo.*COMMAND")#!/bin/bash
# Cron runs with a minimal PATH — commands like free, ss, who, ip may not
# resolve without this explicit path.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
arch=$(uname -a)
pcpu=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
vcpu=$(grep "^processor" /proc/cpuinfo | wc -l)
ram_total=$(free --mega | awk '$1 == "Mem:" {print $2}')
ram_used=$(free --mega | awk '$1 == "Mem:" {print $3}')
ram_percent=$(free --mega | awk '$1 == "Mem:" {printf "%.2f", $3/$2*100}')
disk_total=$(df -BG --total | grep "total" | awk '{print $2}')
disk_used=$(df -BG --total | grep "total" | awk '{print $3}')
disk_percent=$(df -B1 --total | grep "total" | awk '{printf "%.2f", $3/$2*100}')
cpu_load=$(top -bn1 | grep "^%Cpu" | awk '{print $2}')
last_boot=$(who -b | awk '{print $3 " " $4}')
lvm_active=$(lsblk | grep -c "lvm")
lvm_status=$(if [ "$lvm_active" -eq 0 ]; then echo "no"; else echo "yes"; fi)
tcp_connections=$(ss -tln | wc -l)
user_log=$(who | wc -l)
ipv4=$(hostname -I)
mac=$(ip link show | grep "ether" | awk '{print $2}')
sudo_count=$(journalctl | grep -c "sudo.*COMMAND")
wall "
#Architecture: $arch
#CPU physical: $pcpu
#vCPU: $vcpu
#Memory Usage: $ram_used/${ram_total}MB ($ram_percent%)
#Disk Usage: $disk_used/${disk_total} ($disk_percent%)
#CPU load: $cpu_load%
#Last boot: $last_boot
#LVM use: $lvm_status
#Connections TCP: $tcp_connections ESTABLISHED
#User log: $user_log
#Network: IP $ipv4 ($mac)
#Sudo: $sudo_count cmd
"The wall (write all) command sends a message to all currently logged-in users' terminals. It is used in the monitoring script to display system information on all TTYs simultaneously.
wall "message"Alternatively, using a here-doc:
wall << EOF
message
EOFCron is a time-based job scheduler in Unix-like operating systems. It allows users to run scripts or commands at specified times and intervals.
The cron daemon (cron on Debian) reads configuration files called crontabs and executes commands according to their schedule.
System Time → Cron Daemon → Check Crontabs → Execute Commands
* * * * * command_to_run
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ └── Day of week (0-7, 0=Sunday)
│ │ │ └──── Month (1-12)
│ │ └────── Day of month (1-31)
│ └──────── Hour (0-23)
└────────── Minute (0-59)
| Expression | Meaning |
|---|---|
*/10 * * * * |
Every 10 minutes |
0 * * * * |
Every hour |
0 0 * * * |
Every day at midnight |
@reboot |
At system startup |
sudo cp monitoring.sh /usr/local/bin/monitoring.sh
sudo chmod +x /usr/local/bin/monitoring.shsudo crontab -eAdd these lines:
*/10 * * * * /usr/local/bin/monitoring.sh
@reboot /usr/local/bin/monitoring.sh
⚠️ Cron gotcha: Cron runs with a stripped PATH (/usr/bin:/bin). Commands likefree,ss,who,hostname,ipmay not resolve. Fix by either: (a) addingPATH=...at the top ofmonitoring.sh(already done in the full script above), or (b) setting PATH in the crontab:*/10 * * * * PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /usr/local/bin/monitoring.sh @reboot PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /usr/local/bin/monitoring.sh
sudo systemctl status cron
sudo crontab -lDuring the defense, you will be asked to stop the monitoring script from displaying without modifying the script itself.
Two methods:
sudo systemctl stop cron
sudo systemctl status cronThis stops cron entirely, preventing any scheduled job from running.
sudo crontab -eComment out the lines with #:
#*/10 * * * * /usr/local/bin/monitoring.sh
#@reboot /usr/local/bin/monitoring.sh
- VirtualBox (or UTM on Apple Silicon)
- Debian Stable ISO (netinst or DVD image)
- At least 1 GB RAM allocated to VM
- At least 10 GB virtual disk
- Open VirtualBox
- Click New
- Name:
Born2beroot(or your login) - Type: Linux
- Version: Debian (64-bit)
- Memory: 1024 MB
- Hard disk: Create a virtual hard disk now
- Size: 8+ GB (recommend 12.8+ GB for bonus)
- File type: VDI
- Storage: Dynamically allocated
- Attach the Debian ISO to the VM
- Start the VM
- Select Install (not graphical install)
- Language: English
- Location: United States
- Keymap: American English
- Configure the network:
- Hostname: your_login42 (e.g., wil42)
- Domain: (leave blank)
- Root password: Set a strong password
- User account:
- Full name: (your name)
- Username: your_login
- Password: strong password
- Partition disks: Select Manual or Guided - use entire disk with LVM and encryption
If using guided partitioning with LVM and encryption:
- Select Guided - use entire disk with LVM and encryption
- Select the virtual disk
- Choose the partitioning scheme:
- Separate /home, /var, and /swap partitions recommended
- Review partition layout
- Enter encryption passphrase
- Confirm partitioning
Expected layout:
sda1 /boot (unencrypted, ~500 MB)
sda5 LUKS encrypted
└─── debian-vg
├── root → /
├── home → /home
├── var → /var
└── swap → swap
Note: The subject requires at least 2 encrypted partitions. With this scheme, all partitions except
/bootare encrypted under LUKS.
After installation completes, reboot and log in as root.
apt update
apt upgrade -yapt install sudo ufw openssh-server -yThe subject requires your user to be in the user42 group, which does not exist by default on Debian:
groupadd user42usermod -aG sudo your_login
usermod -aG user42 your_loginvisudo -f /etc/sudoers.d/sudoconfigAdd:
Defaults passwd_tries=3
Defaults badpass_message="Incorrect password. Please try again."
Defaults log_input, log_output
Defaults iolog_dir=/var/log/sudo
Defaults requiretty
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
nano /etc/ssh/sshd_configChange:
Port 4242
PermitRootLogin no
Restart SSH:
systemctl restart sshufw allow 4242
ufw enable
ufw statusEdit /etc/login.defs:
PASS_MAX_DAYS 30
PASS_MIN_DAYS 2
PASS_WARN_AGE 7
Apply to existing users:
chage -M 30 -m 2 -W 7 your_login
chage -M 30 -m 2 -W 7 rootapt install libpam-pwquality -yEdit /etc/pam.d/common-password:
password requisite pam_pwquality.so retry=3 minlen=10 ucredit=-1 lcredit=-1 dcredit=-1 maxrepeat=3 reject_username difok=7
See the Password Policy section for the difok/enforce_for_root discussion.
Your login user should already exist from installation. Verify:
id your_loginExpected:
uid=1000(your_login) gid=1000(your_login) groups=1000(your_login),27(sudo),1001(user42)
hostnamectl set-hostname your_login42Edit /etc/hosts:
127.0.0.1 localhost
127.0.1.1 your_login42
nano /usr/local/bin/monitoring.shPaste the script content, then:
chmod +x /usr/local/bin/monitoring.shTest it:
/usr/local/bin/monitoring.shcrontab -eAdd:
*/10 * * * * /usr/local/bin/monitoring.sh
@reboot /usr/local/bin/monitoring.sh
On your host machine (not inside the VM), navigate to the VirtualBox VM folder:
# Linux
sha1sum ~/VirtualBox\ VMs/Born2beroot/Born2beroot.vdi
# macOS
shasum ~/VirtualBox\ VMs/Born2beroot/Born2beroot.vdi
# Windows
certUtil -hashfile "C:\Users\YourName\VirtualBox VMs\Born2beroot\Born2beroot.vdi" sha1Copy the hash into signature.txt at the root of your repository.
Every boot and shutdown changes the .vdi file — logs, timestamps, journal files all get written. If the hash in signature.txt doesn't match the VM disk at evaluation, your grade is 0. Two strategies:
Strategy A — Duplicate (recommended):
- Fully configure the VM, power it off cleanly
- Copy the entire VM folder:
cp -r ~/VirtualBox\ VMs/Born2beroot ~/VirtualBox\ VMs/Born2beroot-eval
- Generate
sha1sumfrom the copy, paste the hash intosignature.txt - Never boot the copy. Use the original as your working VM
- At evaluation, register the copy in VirtualBox: Machine → Add, select the copy's
.vboxfile - The copy's disk is untouched → hash matches → safe
Strategy B — Save state:
- Generate signature from the powered-off VM
- Before evaluation, use Save State (not power off) — this preserves the disk
- At evaluation, resume from saved state
- The disk hash still matches
Why this matters: one evaluation session can permanently invalidate your signature for the next. Duplication or save-state avoids this entirely.
If you chose Rocky Linux instead of Debian, the steps differ. Here is the equivalent installation.
- Boot from the Rocky ISO
- Select Install Rocky Linux 9
- Language: English → Continue
- Installation Destination: select the virtual disk, enable encryption, configure LVM with separate
/home,/var, andswap - Network & Hostname: set hostname to
your_login42, enable the network adapter - Root Password: set a strong password
- User Creation: create your login user, check Make this user administrator (adds to
wheelgroup) - Begin installation
# Update the system
dnf update -y
# Install required packages
dnf install sudo openssh-server firewalld -y
# Create the user42 group
groupadd user42
usermod -aG user42 your_loginRocky uses SELinux instead of AppArmor. The subject requires SELinux to be running at startup:
# Check SELinux status
getenforce # must return "Enforcing"
sestatus # detailed status
# If not enforcing, enable it:
sudo nano /etc/selinux/config
# Set: SELINUX=enforcing
sudo rebootNote: KDump is explicitly not required for Rocky by the subject.
Rocky uses firewalld as its firewall:
# Start and enable firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
# Add SSH on port 4242
sudo firewall-cmd --permanent --add-port=4242/tcp
sudo firewall-cmd --reload
# Verify
sudo firewall-cmd --list-ports
sudo firewall-cmd --list-all| Setting | Debian | Rocky |
|---|---|---|
| SSH config | /etc/ssh/sshd_config |
Same |
| sudo config | visudo -f /etc/sudoers.d/sudoconfig |
Same |
| Password aging | /etc/login.defs |
Same |
| Password complexity | /etc/pam.d/common-password |
/etc/pam.d/system-auth and /etc/pam.d/password-auth |
| PAM quality module | libpam-pwquality (apt) |
libpwquality (dnf) |
# Install password quality module
dnf install libpwquality -y
# Rocky uses /etc/security/pwquality.conf instead of pam args
nano /etc/security/pwquality.conf
# Add or uncomment:
# minlen = 10
# dcredit = -1
# ucredit = -1
# lcredit = -1
# maxrepeat = 3
# difok = 7
# Password aging in /etc/login.defs works identically
PASS_MAX_DAYS 30
PASS_MIN_DAYS 2
PASS_WARN_AGE 7
# Apply to existing users
chage -M 30 -m 2 -W 7 your_login
chage -M 30 -m 2 -W 7 root# Linux host
sha1sum ~/VirtualBox\ VMs/Rocky_Born2beroot/Rocky_Born2beroot.vdiApply the same duplication/save-state strategy described in Step 13.
Use this checklist before evaluation to ensure everything is configured correctly.
- VM boots without errors
- No graphical interface is installed
- Hostname is
your_login42 - No snapshots exist
- Root user exists
- Your login user exists
- Your user is in
sudogroup - Your user is in
user42group - Can create a new user during evaluation
- SSH service is running
- SSH listens on port 4242
- Root login via SSH is denied
- Can connect via
ssh your_login@localhost -p 4242
- UFW is active
- Only port 4242 is open
- Rules persist after reboot
- AppArmor is running
- Profiles are in enforce mode
-
PASS_MAX_DAYSis 30 -
PASS_MIN_DAYSis 2 -
PASS_WARN_AGEis 7 - Password requires 10+ chars
- Password requires uppercase, lowercase, digit
- Max 3 consecutive identical chars
- Password cannot contain username
- Root password follows the same rules
-
passwd_triesis 3 - Custom badpass message is set
- I/O logging is enabled
- Logs go to
/var/log/sudo/ -
requirettyis enabled -
secure_pathis restricted -
visudoconfig is valid
- At least 2 encrypted partitions using LVM
- LUKS encryption is active
- LVM is displayed by
lsblk
-
monitoring.shexists and is executable - Script runs via cron every 10 minutes
- Script runs at server startup
- Script uses
wallto display information - Can stop it without modifying the script
-
README.mdexists -
signature.txtexists with correct hash
During the defense, you will be asked questions about your choices and understanding. Here are common questions with concise, interview-ready answers.
Virtualization is a technology that allows multiple virtual machines to run on a single physical computer. A hypervisor manages access to the physical hardware and isolates each VM. This improves hardware utilization, reduces costs, and provides isolation between systems.
A hypervisor (or Virtual Machine Monitor) is the software layer that creates, runs, and manages virtual machines. It sits between the physical hardware and the VMs, allocating resources and ensuring isolation.
Type 1 hypervisors run directly on the physical hardware without an underlying OS (e.g., VMware ESXi). Type 2 hypervisors run as an application on top of an existing OS (e.g., VirtualBox). Type 1 offers better performance and is used in data centers; Type 2 is easier to use and ideal for learning.
KVM (Kernel-based Virtual Machine) is a virtualization module built into the Linux kernel. It turns Linux into a Type 1-like hypervisor by using hardware virtualization extensions (Intel VT-x/AMD-V). It powers many enterprise and cloud platforms.
Both are package managers for Debian. apt is the modern, command-line-focused tool that is installed by default and used in most documentation. aptitude is a higher-level tool with better dependency resolution and an interactive text interface. For Born2beroot, apt is the preferred choice.
LVM (Logical Volume Manager) is a storage management layer that provides flexible disk management. It consists of Physical Volumes (PVs), Volume Groups (VGs), and Logical Volumes (LVs). LVM allows resizing, snapshots, and pooling of multiple disks.
A Physical Volume is a storage device (disk or partition) initialized for use by LVM. A Volume Group is a pool of storage created by combining one or more Physical Volumes. Logical Volumes are then allocated from this pool.
LUKS (Linux Unified Key Setup) is the standard for Linux disk encryption. It manages encryption keys and protects data at rest. LUKS uses symmetric encryption (typically AES) and supports multiple passphrases through key slots.
Symmetric encryption uses the same key to encrypt and decrypt (e.g., AES). It is fast and used for encrypting data at rest. Asymmetric encryption uses a public/private key pair (e.g., RSA). It is slower and used for key exchange, SSH, and digital signatures. LUKS uses symmetric encryption; SSH uses both types.
- Client connects to server on port 22 (or 4242)
- Server identifies itself with its host key
- Client and server establish a shared symmetric session key using Diffie-Hellman key exchange
- Client authenticates (password or public key)
- Encrypted session begins
The root username is known, so attackers only need the password. Root has unrestricted privileges, so compromise causes maximum damage. Logging in as a regular user and using sudo provides accountability through logs.
AppArmor is a Mandatory Access Control (MAC) system that confines programs to a limited set of resources. It uses profiles to define what files, network, and capabilities a program can access. Profiles run in enforce or complain mode.
Both are MAC systems. AppArmor is path-based (simpler) and default on Debian/Ubuntu. SELinux is label-based (more granular but complex) and default on RHEL/Rocky/Fedora.
PAM (Pluggable Authentication Modules) is a framework for authentication on Linux. It allows administrators to configure authentication methods independently of applications. PAM modules control password complexity, account expiration, session management, and more.
sudo provides granular control over who can run which commands, logs all privileged actions for accountability, uses the user's password (not root's), and keeps the user's environment. This follows the principle of least privilege.
A firewall controls incoming/outgoing network traffic based on security rules. It reduces the attack surface by only allowing necessary ports (e.g., 4242 for SSH) and blocks all unauthorized access attempts.
The wall (write all) command displays a message on all terminals of all logged-in users. This ensures that system information is visible regardless of which TTY the evaluator is viewing.
Cron is a time-based scheduler. The cron daemon checks crontab files for scheduled commands and executes them at the specified times. The syntax is: minute hour day month weekday command.
Stop the cron daemon with sudo systemctl stop cron. This prevents all scheduled jobs from running. Alternatively, comment out the lines in root's crontab with sudo crontab -e.
Evaluators will ask you to change the hostname to verify you understand how it works:
# 1. Check current hostname
hostnamectl
# 2. Set new hostname (your login + 42)
sudo hostnamectl set-hostname yourlogin42
# 3. Update /etc/hosts to match
sudo nano /etc/hosts
# Change: 127.0.1.1 oldname → 127.0.1.1 yourlogin42
# 4. Verify
hostnamectl
hostname
# 5. Reboot to confirm persistence
sudo rebootAfter reboot, reconnect via SSH and verify the prompt shows the new hostname.
The subject states: "During the defense, you will have to create a new user and assign it to a group."
# 1. Create user with home directory and bash shell
sudo useradd -m -s /bin/bash evaluator
# 2. Set a password (must follow your password policy!)
sudo passwd evaluator
# 3. Add to a group
sudo usermod -aG sudo evaluator # grant sudo access
# or
sudo usermod -aG user42 evaluator # project-specific group
# 4. Verify
id evaluator
groups evaluator
# 5. Test (if added to sudo)
su - evaluator
sudo whoami # should print "root"uname -a # All system info
hostnamectl # Hostname details
lscpu # CPU information
free -h # Memory usage
df -h # Disk usage
lsblk # Block devices
blkid # Block device attributessudo systemctl status <service> # Check service status
sudo systemctl start <service> # Start a service
sudo systemctl stop <service> # Stop a service
sudo systemctl restart <service> # Restart a service
sudo systemctl reload <service> # Reload configuration
systemctl list-units # List all unitsid <username> # User info
groups <username> # User's groups
sudo useradd -m <user> # Create user
sudo passwd <user> # Set password
sudo usermod -aG <group> <user> # Add user to group
sudo userdel -r <user> # Delete user + homess -tlnp # Listening ports
ip a # IP addresses
ip link show # Network interfaces
hostname -I # IP address
ping -c 4 localhost # Test connectivitysudo ufw status # Firewall status
sudo aa-status # AppArmor status
sudo chage -l <user> # Password aging info
sudo sudoreplay -l # List sudo logs
journalctl | grep sudo # View sudo commandsjournalctl -xe # System logs
sudo tail -f /var/log/syslog # System log
ls -la /var/log/sudo/ # Sudo I/O logs
dmesg # Kernel messages# Check SSH service
sudo systemctl status ssh
# Check port
ss -tlnp | grep 4242
# Check firewall
sudo ufw status
# Check SSH config
sudo grep -E "Port|PermitRootLogin" /etc/ssh/sshd_config# Check authorized_keys permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
# Ensure SSH allows key auth
sudo grep PubkeyAuthentication /etc/ssh/sshd_configIf you enabled UFW before allowing SSH:
# From the VM console (not SSH)
sudo ufw allow 4242Check for conflicts with other firewall tools:
sudo ufw disable
sudo ufw reset
sudo ufw enableBoot in recovery mode or use root:
# As root
usermod -aG sudo your_loginAlways use visudo to edit sudoers files. If locked out:
# Boot in single-user mode
# Or use pkexec
pkexec visudoChanges to /etc/login.defs apply only to new users. Use chage for existing users.
# Verify pam_pwquality is installed
dpkg -l | grep pam_pwquality
# Check config
grep pam_pwquality /etc/pam.d/common-passwordCron has a limited PATH. Use absolute paths in the script:
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binCron jobs run with root privileges if added to root's crontab. Verify:
sudo crontab -lsudo pvs
sudo vgs
sudo lvssudo dmesg | grep crypt
sudo cryptsetup status sda5_cryptThe subject forbids snapshots. Remove them before evaluation:
# In VirtualBox Manager: Right-click VM → Snapshots → Delete allAfter evaluation, the VM signature may change. To preserve:
- Use Save State instead of powering off
- Or duplicate the VM before evaluation
- Generate a new
signature.txtif necessary
| Resource | Description |
|---|---|
| IBM: What is Virtualization? | Comprehensive introduction to virtualization concepts |
| IBM: What is a Hypervisor? | Detailed explanation of hypervisors and their types |
| VMware: Bare Metal Hypervisor | Deep dive into Type 1 hypervisors |
| Red Hat: What is KVM? | KVM virtualization explained |
| Resource | Description |
|---|---|
| Wikipedia: LVM | Comprehensive LVM reference |
| Linux Handbook: LVM Guide | Practical LVM tutorial with examples |
| EaseUS: Logical vs Primary Partition | Clear explanation of partition types |
| Resource | Description |
|---|---|
| Packagecloud: apt vs aptitude | In-depth comparison |
| Resource | Description |
|---|---|
| Medium: Symmetric and Asymmetric Encryption | Clear explanation of encryption types |
| DigitalOcean: Understanding SSH Encryption | Complete guide to SSH encryption and connection process |
| SSH.com: sshd | SSH server process documentation |
| OSTechNix: Password Policies in Linux | Guide to configuring password policies |
| Resource | Description |
|---|---|
| DigitalOcean: UFW Essentials | Common UFW commands and rules |
| DigitalOcean: iptables Essentials | iptables firewall rules reference |