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.
cd /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
The script automatically shuts down the VM after completion. Then in VMware vCenter/vSphere:
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.
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 # Make executable chmod +x *.sh
Run 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.Enables UFW with SSH (22), HTTP (80), HTTPS (443). Blocks everything else. Docker-safe.
sudo bash ufw-firewall-setup.shConfigures 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.shSets up daily file integrity checks and weekly baseline updates via cron.
sudo bash aide-cron-setup.shImports 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-ipAddresses remaining Lynis suggestions: sysstat, debsums, banners, SSH tweaks, service hardening, sysctl.
sudo bash lynis-fixes.shsudo reboot# 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
/var/log/aide/Dailycurl -sO https://www.golu.net/scripts/set-static-ip.sh && sudo bash set-static-ip.sh
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