Deep Security Audit of Ubuntu Lightsail Server

โš™๏ธ Environment Summary:

  • Server: Ubuntu 20.04 LTS (Lightsail)
  • Services Running:
    • Apache2 (2 websites)
    • Email Server (Postfix/Dovecot assumed)
    • Log Server (Syslog or custom logging)
  • Goals: Audit for vulnerabilities, misconfiguration, and unnecessary exposure. Harden system and prepare a final report.

๐Ÿงพ Audit Checklist (Manual + Scripted)

๐Ÿ” 1. SSH Security Review

cat /etc/ssh/sshd_config
  • โœ”๏ธ Check for PermitRootLogin, PasswordAuthentication, Port, MaxAuthTries, AllowUsers
  • โœ”๏ธ Enforced non-root sudo user with SSH key
  • โœ”๏ธ Changed SSH port to 2222
  • โœ”๏ธ Set MaxAuthTries 3, LoginGraceTime 30, AllowUsers clientadmin
  • ๐Ÿ› ๏ธ Used Fail2Ban to block brute-force attempts
sudo apt install fail2ban -y

๐Ÿ” 2. User and Group Audit

getent passwd | awk -F: '$3 >= 1000 {print $1}'
sudo getent group sudo
lastlog
  • โœ”๏ธ Removed unused users
  • โœ”๏ธ Checked for users with shell access but no clear role
  • โœ”๏ธ Reviewed sudoers, disabled passwordless sudo where not needed
  • โœ”๏ธ Ran lastlog and who to check logins

๐Ÿ” 3. Open Ports + Services Audit

sudo ss -tuln
sudo netstat -tuln | grep LISTEN
  • โœ”๏ธ Open ports: 80, 443, 2222, 25/465/587 (email)
  • โŒ Found MySQL exposed on 3306 (locked down using UFW)
  • โœ”๏ธ Disabled unused services using systemctl disable xyz

๐Ÿ”ฅ 4. Firewall and Network Rules

sudo ufw status numbered
sudo iptables -L
  • โœ”๏ธ UFW rules enforced for minimal surface
  • โœ”๏ธ Only 80, 443, 2222, email ports allowed
  • โœ”๏ธ Deny by default + outbound allowed
  • โœ”๏ธ ICMP echo requests dropped (optional)

๐Ÿ 5. Malware + Rootkit Scan

sudo apt install chkrootkit rkhunter lynis -y
sudo chkrootkit
sudo rkhunter --check
sudo lynis audit system
  • โœ”๏ธ No rootkits found
  • โœ”๏ธ Lynis reported outdated packages, fixed with full system update

๐Ÿงช 6. File System and SUID/GUID Audit

find / -perm /6000 -type f 2>/dev/null
  • โœ”๏ธ Identified and reviewed all SUID binaries
  • โœ”๏ธ Restricted or removed dangerous ones (e.g., nmap, netcat if present)

๐Ÿ“ฆ 7. Package Audit

dpkg -l | grep -E "telnet|ftp|netcat"
  • โŒ Found legacy packages like telnet (removed)
  • โœ”๏ธ Enabled unattended-upgrades for automatic patching
sudo apt install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades

๐Ÿ” 8. Apache and Website Security Review

cat /etc/apache2/sites-enabled/*.conf
  • โœ”๏ธ Checked for missing ServerTokens, ServerSignature
  • โœ”๏ธ Disabled .htaccess overrides where possible
  • โœ”๏ธ Enabled HTTPS redirect, HSTS headers
  • โœ”๏ธ Scanned site using:

๐Ÿ“ง 9. Email Server Checks

sudo systemctl status postfix
sudo postconf -n
  • โœ”๏ธ Verified SMTP AUTH, SSL on mail ports
  • โœ”๏ธ Checked SPF/DKIM/DMARC DNS records
  • โœ”๏ธ Checked /var/log/mail.log for spam attempts

๐Ÿ“‚ 10. Log Configuration and Centralization

ls /var/log/
sudo cat /etc/rsyslog.conf
  • โœ”๏ธ Verified logs were rotated and stored properly
  • โœ”๏ธ Installed and configured logwatch for daily summaries
  • Optional: Configured central logging to a secondary log server (client-dependent)

๐Ÿ“‹ Sample Summary Report (Client Delivered)

## Security Audit Summary โ€“ Client Lightsail Server

**Date:** 2025-02-22
**Auditor:** mkcloudai.com

### Key Fixes:
- Disabled root login
- Enforced SSH keys
- Closed exposed MySQL port
- Hardened Apache2 and added SSL
- Scanned for malware/rootkits
- Hardened UFW rules
- Cleaned up unused users/services

**Score (pre-audit):** 45/100
**Score (post-audit):** 85/100 (based on CIS + Lynis)

**Recommendations:**
- Enable 2FA for admin panel/email
- Monitor logs via Fail2Ban + Logwatch
- Perform quarterly audits

โœ… Final Deliverables Recap:

  • Security audit scripts
  • Audit report (Markdown/PDF)
  • Hardened system
  • SSL setup and troubleshooting
  • Email + website confirmed working
  • GitHub repo and full write-up
Scroll to Top