Server Setup
Complete Ubuntu 24.04 Build & Hardening Guide
Start with a fresh Ubuntu 24.04 VM in VMware. Run the golden image script to install tools, import SSH keys, harden the base, and prepare the VM for template conversion. This only runs once.
Download & Run Golden Image Script
~10 minutescd /tmp curl -sO https://www.golu.net/scripts/Linux-Golden-template.sh chmod +x Linux-Golden-template.sh sudo bash Linux-Golden-template.sh
Enter GitHub username for SSH key import: — your GitHub handleEnter primary username (e.g. ubuntu): — the user you SSH in with
Convert to Template
The script automatically shuts down the VM after completion. Then in VMware vCenter/vSphere:
2. Or take a Snapshot for linked clones
3. Your golden image is ready — deploy new VMs from it
After deploying a new VM from the golden image template, SSH in and run these scripts to apply full CIS hardening, firewall, auto-updates, integrity monitoring, and Lynis fixes.
Download All Scripts
~10 secondscd /tmp curl -sO https://www.golu.net/scripts/cis-safefix-ubuntu24-docker-Part1.sh curl -sO https://www.golu.net/scripts/cis-safefix-ubuntu24-docker-Part2.sh curl -sO https://www.golu.net/scripts/cis-safefix-ubuntu24-docker-Part3.sh curl -sO https://www.golu.net/scripts/ufw-firewall-setup.sh curl -sO https://www.golu.net/scripts/auto-security-updates.sh curl -sO https://www.golu.net/scripts/aide-cron-setup.sh curl -sO https://www.golu.net/scripts/ssh-key-lynis-setup.sh curl -sO https://www.golu.net/scripts/lynis-fixes.sh # Make executable chmod +x *.sh
CIS Hardening
~5 minutesRun all three parts in order. Part 1 will prompt for your primary username.
sudo bash cis-safefix-ubuntu24-docker-Part1.sh sudo bash cis-safefix-ubuntu24-docker-Part2.sh sudo bash cis-safefix-ubuntu24-docker-Part3.sh
Enter primary username (e.g. ubuntu): — enter the user you SSH in with.UFW Firewall
~30 secondsEnables UFW with SSH (22), HTTP (80), HTTPS (443). Blocks everything else. Docker-safe.
sudo bash ufw-firewall-setup.shAutomatic Security Updates
~30 secondsConfigures unattended-upgrades for security patches. Auto-reboots at 3:00 AM if needed (only when no users are logged in).
sudo bash auto-security-updates.shAIDE Integrity Monitoring
~2 minutesSets up daily file integrity checks and weekly baseline updates via cron.
sudo bash aide-cron-setup.shSSH Key + Lynis Audit
~3 minutesImports your GitHub SSH public keys, disables password authentication, clones Lynis, and runs a full audit. Will prompt for your GitHub username.
sudo bash ssh-key-lynis-setup.shssh user@server-ipLynis Fixes
~1 minuteAddresses remaining Lynis suggestions: sysstat, debsums, banners, SSH tweaks, service hardening, sysctl.
sudo bash lynis-fixes.shReboot
requiredsudo rebootVerify After Reboot
optional# Check SSH sudo systemctl status ssh # Check firewall sudo ufw status verbose # Check auditd sudo systemctl status auditd sudo auditctl -s # Check AIDE sudo aide --config=/etc/aide/aide.conf --check # Check auto-updates systemctl list-timers apt-* # Check Lynis score cd /opt/lynis && sudo ./lynis audit system # Check network ip a && ip route
What Runs Automatically
/var/log/aide/DailySet Static IP (When Needed)
curl -sO https://www.golu.net/scripts/set-static-ip.sh && sudo bash set-static-ip.sh
One-Liner — Clone VM Setup
Downloads and runs all clone VM scripts sequentially. You'll be prompted for your username in CIS Part 1.
cd /tmp && \ curl -sO https://www.golu.net/scripts/cis-safefix-ubuntu24-docker-Part1.sh && \ curl -sO https://www.golu.net/scripts/cis-safefix-ubuntu24-docker-Part2.sh && \ curl -sO https://www.golu.net/scripts/cis-safefix-ubuntu24-docker-Part3.sh && \ curl -sO https://www.golu.net/scripts/ufw-firewall-setup.sh && \ curl -sO https://www.golu.net/scripts/auto-security-updates.sh && \ curl -sO https://www.golu.net/scripts/aide-cron-setup.sh && \ curl -sO https://www.golu.net/scripts/ssh-key-lynis-setup.sh && \ curl -sO https://www.golu.net/scripts/lynis-fixes.sh && \ chmod +x *.sh && \ sudo bash cis-safefix-ubuntu24-docker-Part1.sh && \ sudo bash cis-safefix-ubuntu24-docker-Part2.sh && \ sudo bash cis-safefix-ubuntu24-docker-Part3.sh && \ sudo bash ufw-firewall-setup.sh && \ sudo bash auto-security-updates.sh && \ sudo bash aide-cron-setup.sh && \ sudo bash ssh-key-lynis-setup.sh && \ sudo bash lynis-fixes.sh && \ sudo reboot