Every day, servers are compromised not because of sophisticated zero-day exploits, but because admins skip fundamental security steps. A default SSH port here, a forgotten test user there, and suddenly you're dealing with unauthorized access or worse. This checklist walks through the most common mistakes and shows you exactly how to fix them.
Mistake 1: Running SSH on the Default Port with Password Auth
What admins do wrong: Leaving SSH running on port 22 with password authentication enabled is like hanging a neon sign that says "try to break in here." Automated scanners constantly probe port 22, attempting thousands of password combinations.
The correct approach:
Change your SSH port and disable password authentication entirely:
# Edit SSH config
sudo nano /etc/ssh/sshd_config
# Change these lines:
Port 2222 # Pick a high port number
PasswordAuthentication no
PermitRootLogin no
PubkeyAuthentication yes
Before disabling password auth, ensure you have SSH keys set up:
# On your local machine, generate a key if you don't have one
ssh-keygen -t ed25519 -C "[email protected]"
# Copy it to your server
ssh-copy-id -p 22 user@your-server-ip
# Test the key auth works before disabling passwords
ssh -p 22 user@your-server-ip
Only after confirming key authentication works, restart SSH:
sudo systemctl restart sshd
Critical: Keep your current SSH session open while testing the new configuration in a separate terminal. If something breaks, you can still fix it.
Mistake 2: Not Configuring a Firewall (or Leaving Everything Open)
What admins do wrong: Many admins either never enable a firewall or configure it with overly permissive rules like allowing all traffic. Some enable UFW or firewalld but forget to actually deny the default incoming traffic.
The correct approach:
Implement a default-deny policy and explicitly allow only necessary services:
# For UFW (Ubuntu/Debian)
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 2222/tcp # Your SSH port
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose
# For firewalld (CentOS/RHEL/Rocky)
sudo firewall-cmd --set-default-zone=drop
sudo firewall-cmd --zone=public --add-port=2222/tcp --permanent
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
Review your rules monthly. If you opened port 8080 for testing six months ago and never closed it, you have an unnecessary attack surface.
Mistake 3: Ignoring System Updates
What admins do wrong: Admins worry that updates will break something, so they postpone them indefinitely. Meanwhile, known vulnerabilities remain unpatched and exploitable.
The correct approach:
Enable automatic security updates for critical patches, but retain control over major version upgrades:
# Debian/Ubuntu - install unattended-upgrades
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
# Configure to auto-install security updates only
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
For CentOS/RHEL, use dnf-automatic:
sudo dnf install dnf-automatic
sudo systemctl enable --now dnf-automatic.timer
# Edit /etc/dnf/automatic.conf
# Set: apply_updates = yes (for security only)
Schedule a monthly maintenance window to manually review and apply non-security updates after testing in a staging environment.
Mistake 4: Running Services as Root
What admins do wrong: Running web servers, databases, or applications as the root user means that if an attacker compromises that service, they immediately have full system control.
The correct approach:
Every service should run under its own limited user account:
# Create a dedicated user for an application
sudo useradd -r -s /bin/false appuser
# Set ownership of application files
sudo chown -R appuser:appuser /opt/myapp
# Configure the service to run as that user
# In systemd unit file:
[Service]
User=appuser
Group=appuser
Verify services are not running as root:
# Check what user a process runs as
ps aux | grep nginx
ps aux | grep mysql
If you see root in the output for application processes (not just master processes that need to bind to privileged ports), investigate and fix the configuration.
Mistake 5: Weak or Reused Passwords Across Accounts
What admins do wrong: Using the same password for the server admin account, database root, and control panel creates a single point of failure. Weak passwords like "Password123" or "ServerAdmin2024" fall instantly to dictionary attacks.
The correct approach:
Use unique, complex passwords for every account and service. Store them in a password manager:
# Generate strong passwords on the command line
openssl rand -base64 32
# Or use pwgen if installed
pwgen -s 32 1
For database access, applications should use dedicated database users with minimal privileges, never the root account:
-- MySQL/MariaDB example
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'strong-unique-password';
GRANT SELECT, INSERT, UPDATE, DELETE ON appdb.* TO 'appuser'@'localhost';
FLUSH PRIVILEGES;
Rotate passwords for critical accounts quarterly and immediately after any suspected compromise or when team members leave.
Mistake 6: Leaving Unnecessary Services Running
What admins do wrong: Default OS installations often start services you don't need. Every running service is a potential entry point—especially if it has vulnerabilities or is misconfigured.
The correct approach:
Audit running services and disable anything you don't actively use:
# List all running services
sudo systemctl list-units --type=service --state=running
# For each service you don't recognize or need:
sudo systemctl stop servicename
sudo systemctl disable servicename
Common services to evaluate: - avahi-daemon: mDNS/Bonjour; rarely needed on servers - cups: Printing service; unnecessary on most servers - bluetooth: Almost never needed on a server - rpcbind: Only needed if you're using NFS
After disabling services, verify your applications still work as expected.
Mistake 7: Not Monitoring Logs or Setting Up Fail2Ban
What admins do wrong: Logs accumulate without anyone reviewing them. Thousands of failed SSH attempts go unnoticed, and there's no automated response to block attackers.
The correct approach:
Install and configure fail2ban to automatically block IPs after repeated failed attempts:
# Install fail2ban
sudo apt install fail2ban # Debian/Ubuntu
sudo dnf install fail2ban # CentOS/RHEL
# Create local config
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
Basic configuration:
[DEFAULT]
bantime = 3600
findtime = 600
maxretry = 5
[sshd]
enabled = true
port = 2222 # Your custom SSH port
Start and enable:
sudo systemctl enable --now fail2ban
sudo fail2ban-client status sshd
Regularly review logs for patterns:
# Check auth logs
sudo tail -f /var/log/auth.log # Debian/Ubuntu
sudo tail -f /var/log/secure # CentOS/RHEL
# Review fail2ban activity
sudo fail2ban-client status
Consider shipping logs to a centralized system so they survive if the server is compromised.
Mistake 8: Incorrect File Permissions and Ownership
What admins do wrong: Setting permissions to 777 (world-writable) or leaving sensitive config files readable by all users exposes credentials and allows unauthorized modification.
The correct approach:
Apply the principle of least privilege:
# Web application files: owner can write, group/others read-only
sudo find /var/www/html -type f -exec chmod 644 {} \;
sudo find /var/www/html -type d -exec chmod 755 {} \;
# Configuration files with secrets: owner read-only
sudo chmod 600 /etc/myapp/config.ini
sudo chown appuser:appuser /etc/myapp/config.ini
# SSH keys must be restrictive
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/id_ed25519.pub
chmod 600 ~/.ssh/authorized_keys
Regularly audit for overly permissive files:
# Find world-writable files (potential security risk)
sudo find / -type f -perm -002 -ls 2>/dev/null
# Find files with SUID bit (review carefully)
sudo find / -type f -perm -4000 -ls 2>/dev/null
Investigate anything unexpected in these results.
Mistake 9: No Backup Strategy or Untested Backups
What admins do wrong: Admins either don't back up at all, or they configure backups but never test restoration. When disaster strikes—ransomware, hardware failure, accidental deletion—they discover their backups are corrupted or incomplete.
The correct approach:
Implement the 3-2-1 rule: three copies of data, on two different media types, with one offsite.
# Example: automated daily backup with rsync
# Create backup script
sudo nano /usr/local/bin/backup.sh
#!/bin/bash
BACKUP_DIR="/backup/daily"
SOURCE_DIRS="/var/www /etc /home"
DATE=$(date +%Y%m%d)
rsync -avz --delete $SOURCE_DIRS $BACKUP_DIR/$DATE/
# Keep only last 7 days
find $BACKUP_DIR -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
# Make executable and schedule
sudo chmod +x /usr/local/bin/backup.sh
sudo crontab -e
# Add: 0 2 * * * /usr/local/bin/backup.sh
Critical: Schedule quarterly restoration tests. Pick a random backup, spin up a test VM, and restore from that backup to verify it works.
Mistake 10: Using Outdated Software Versions
What admins do wrong: Continuing to use end-of-life operating systems or software versions that no longer receive security patches because "it still works" or migration seems difficult.
The correct approach:
Track end-of-life dates for your entire stack and plan migrations well in advance:
- Operating system: Upgrade to supported LTS releases before current version reaches EOL
- Web server: Keep Apache, Nginx, or LiteSpeed on supported branches
- Database: MariaDB, MySQL, and PostgreSQL all publish support timelines
- PHP, Python, Node.js: Language runtimes have clear EOL schedules
Check your current versions:
cat /etc/os-release
apache2 -v # or nginx -v
mysql --version
php -v
If any component is past or approaching EOL, prioritize upgrading. The cost of migration is always less than the cost of a breach.
Mistake 11: Exposing Sensitive Services to the Internet
What admins do wrong: Database ports (3306, 5432), Redis (6379), Memcached (11211), or admin panels are left listening on public IP addresses where anyone can probe them.
The correct approach:
Bind services to localhost unless they genuinely need external access:
# MySQL/MariaDB - edit /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address = 127.0.0.1
# Redis - edit /etc/redis/redis.conf
bind 127.0.0.1
# PostgreSQL - edit /etc/postgresql/*/main/postgresql.conf
listen_addresses = 'localhost'
For services that do need network access, use firewall rules to restrict by source IP:
# Allow MySQL only from application server
sudo ufw allow from 192.168.1.50 to any port 3306 proto tcp
After configuration changes, restart services and verify they're only listening where intended:
sudo netstat -tlnp | grep :3306
sudo ss -tlnp | grep :6379
Mistake 12: No Security Monitoring or Intrusion Detection
What admins do wrong: Servers run without any form of monitoring. Compromises go undetected for weeks or months because no one is watching for suspicious activity.
The correct approach:
Implement basic host-based intrusion detection:
# Install AIDE (Advanced Intrusion Detection Environment)
sudo apt install aide # Debian/Ubuntu
sudo dnf install aide # CentOS/RHEL
# Initialize database
sudo aideinit
sudo mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db
# Schedule daily checks
sudo crontab -e
# Add: 0 5 * * * /usr/bin/aide --check | mail -s "AIDE Report" [email protected]
Monitor for: - Unexpected file changes in system directories - New users or groups created - Changes to sudoers or SSH authorized_keys - Unusual network connections - Spikes in resource usage
Consider tools like Lynis for security auditing:
sudo apt install lynis
sudo lynis audit system
Review the report and address high-priority findings.
Conclusion
Server security doesn't require exotic tools or advanced techniques. Most compromises happen because admins skip basics: SSH still accepts passwords, firewalls allow everything, services run as root, and software never gets updated. Work through this checklist methodically. Fix one mistake at a time, test each change, and document what you did. Your server won't be invulnerable—nothing is—but you'll eliminate the easy wins that attackers count on. Start with SSH and firewall configuration today, then work through the rest over the next week. Future you will thank current you when the next vulnerability scanner comes knocking and finds nothing to exploit.
