- Introduction
- System Information
- Installation Guide
- Partitioning Scheme
- User and Group Management
- SSH Configuration
- Firewall Configuration (UFW)
- Password Policies
- Monitoring Setup
- Cron Jobs
- Bonus Features
- Conclusion
The Born2beRoot project is part of the 42 school curriculum. The goal is to configure a Linux-based virtual machine (VM) with essential system administration tools, focusing on security, service management, and automated tasks.
The project helps students build a solid foundation in system administration by setting up a secure and efficient server environment using either Debian or CentOS.
- Operating System: [Debian/CentOS] (Choose based on your project)
- Kernel Version: [e.g., Linux 5.10]
- Virtual Machine: VirtualBox or UTM
- Virtualization Software: I used VirtualBox/UTM to create a new virtual machine.
- ISO Download: Download the official Debian or CentOS ISO image.
- Boot the VM with the ISO image and follow the installation steps.
- Configure the hostname and root password during the installation.
- Partition the disk using the LVM setup (details below).
sudo apt update && sudo apt upgrade
or
sudo yum update
For this project, I used LVM (Logical Volume Manager) to manage the disk partitions efficiently.
Partition | Mount Point | Type | Size |
---|---|---|---|
/dev/sda1 |
/boot |
ext4 | 512MB |
/dev/sda2 |
LVM PV |
LVM | Remaining space |
LVM Root |
/ |
ext4 | 10GB |
LVM Swap |
swap |
swap | 2GB |
LVM Home |
/home |
ext4 | 5GB |
This setup allows for flexible management of storage space and easy resizing in the future.
I created specific users and groups as required, focusing on user permissions and security:
- Root user: The root account is secured with a strong password and is disabled for SSH login.
- New User:
- Username:
username
- Group:
sudo
- Home directory created at
/home/username
- Username:
adduser username usermod -aG sudo username
- Group Creation: I created additional groups for file permissions and management as needed.
SSH is used to remotely manage the server securely.
-
Installed and enabled the SSH service:
sudo apt install openssh-server sudo systemctl enable ssh sudo systemctl start ssh
-
Root login disabled for security reasons:
-
In
/etc/ssh/sshd_config
, set:PermitRootLogin no
-
-
Changed the default SSH port from
22
to4242
to enhance security:Port 4242
-
Restarted the SSH service:
sudo systemctl restart ssh
The firewall is configured to allow only essential services.
-
Installed UFW and enabled it:
sudo apt install ufw sudo ufw enable
-
Allowed SSH on the new port:
sudo ufw allow 4242/tcp
-
Check the status:
sudo ufw status
To enforce strong password policies, I configured PAM (Pluggable Authentication Modules) by editing /etc/login.defs
and /etc/pam.d/common-password
:
- Password must be at least 10 characters long.
- Enforced password complexity (uppercase, lowercase, digits, and special characters).
sudo nano /etc/login.defs
Set:
PASS_MAX_DAYS 30 PASS_MIN_DAYS 2 PASS_MIN_LEN 10 PASS_WARN_AGE 7
For more control:
sudo nano /etc/pam.d/common-password
Add:
password requisite pam_pwquality.so retry=3 minlen=10 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1
I created a bash script that outputs system information every 10 minutes and logs it to a file.
- CPU Usage
- RAM Usage
- Disk Usage
- Logged-in users
- Last boot time
Sample script:
#!/bin/bash wall "Monitoring: ----------------- CPU Load: $(top -bn1 | grep load | awk '{printf "%.2f", $(NF-2)}') Memory Usage: $(free -m | awk 'NR==2{printf "%.2f", $3*100/$2 }') Disk Usage: $(df -h | awk '$NF=="/"{printf "%s", $5}') Last boot: $(who -b | awk '{print $3, $4}')"
This script is added to a cron job for execution every 10 minutes.
I set up a cron job to run the monitoring script:
crontab -e
Add the following line:
*/10 * * * * /path/to/monitoring_script.sh
As part of the bonus, I implemented:
- Fail2Ban: To protect the SSH server from brute-force attacks.
- Custom Bash Prompt: A personalized and more informative bash prompt.
- Additional Partitioning: More complex partition setups for
/var
and/tmp
.
The Born2beRoot project was a great introduction to system administration and security practices. By completing this project, I gained hands-on experience with setting up and securing a Linux server, managing users, configuring SSH, and ensuring the system is monitored and secured with firewall rules and cron jobs.
This README file covers the essential details and configurations of the Born2beRoot project. You can extend it further by adding more details specific to your VM setup or additional bonus features you implement.