Secure Your VPS: Simple Hardening Steps

Securing your VPS is essential to protect data, applications, and uptime. While these steps apply broadly, we’ll use Ubuntu as an example for commands.
1. Keep Your System Updated
Outdated software is the easiest way in for attackers.
Actionable steps (Ubuntu example):
1sudo apt update && sudo apt upgrade -y 2sudo apt install unattended-upgrades -y 3sudo dpkg-reconfigure --priority=
Automatic updates ensure critical security patches are applied without manual intervention.
2. Secure SSH Access (Most Critical)
SSH is the main access point for your server and should be locked down.
Best practices:
- Disable root login: Edit
/etc/ssh/sshd_config:
PermitRootLogin no
- Use SSH keys only, disable passwords:
PasswordAuthentication no
PubkeyAuthentication yes
- Change the default SSH port: e.g.,
2022:
Port 2022
- Enable brute-force protection using fail2ban or similar tools.
- Optional: Multi-factor authentication for SSH.
Real-world: SSH keys + port change + root disabled blocks 99% of automated attacks immediately.
3. Configure a Firewall
Lock down which ports your server accepts connections on.
Example (Ubuntu + ufw):
1sudo apt install ufw -y 2sudo ufw default deny incoming 3sudo ufw default allow outgoing 4sudo ufw allow 2022/tcp # SSH 5
Only open what’s necessary. Keep everything else blocked.
4. Disable Unnecessary Services
Each service you don’t use is an attack surface.
Actionable steps:
- List running services:
1systemctl list-units --type=service --state=running
- Disable anything unnecessary:
1sudo systemctl disable --now service_name
- Remove packages that are not needed:
1sudo apt purge package_name -y
5. Strong Users & Permissions
Limit privileges and remove shared accounts.
Guidelines:
- Add a non-root admin:
1sudo adduser alice 2sudo usermod -aG sudo alice
- Remove or lock unused accounts:
1sudo userdel olduser 2sudo passwd -l root
- Only use
sudofor administrative tasks.
6. Network & Application Hardening
- Disable unused protocols (FTP, Telnet, etc.).
- Use HTTPS and secure protocols for web apps.
- Configure web servers to hide version info and minimize data leaks.
- Enable logging and monitor for suspicious activity.
7. Backups & Monitoring
- Schedule automated backups (local + off-site).
- Monitor server performance and logs.
- Test restores to ensure backups work when needed.
8. Optional Advanced Security
For high-value servers:
- Intrusion Detection (OSSEC, Snort).
- Containerized apps to isolate workloads.
- VPN-only admin access.
- Encrypt sensitive data (disk + network).
Summary
Direct and practical:
- Keep the system updated.
- SSH keys only, root disabled, port changed (e.g., 2022).
- Firewall blocks all unnecessary ports.
- Minimal services running.
- Least-privilege users.
- Regular backups and monitoring.
Consistently applying updates, SSH key access, minimal services, and monitoring keeps your VPS secure and reliable.
