Secure your VPS and install Dokploy in one command.
curl -sSL https://raw.githubusercontent.com/alexandreravelli/vps-hardening-script-ubuntu-24.04-LTS/main/setup.sh -o setup.sh
chmod +x setup.sh
./setup.shThe script runs 9 steps interactively:
- Create admin user - New sudo user with password
- Configure SSH key - Paste your public key
- Update system - apt update/upgrade
- Install security tools - UFW + Fail2Ban
- Configure firewall - Opens only necessary ports
- Harden SSH - Custom port, disable root login
- Install Docker - With log rotation
- Install Dokploy - Self-hosted deployment platform
- Remove old user - Optional cleanup
| Feature | Description |
|---|---|
| SSH | Random port (50000-60000), root disabled, key-only auth |
| Firewall | UFW with deny-by-default, only SSH/80/443/3000 open |
| Fail2Ban | Protects SSH (3 attempts, 1h ban) |
| Rate limiting | UFW limits SSH to 6 connections/30s per IP |
| Password policy | Min 12 chars, mixed case, numbers, symbols required |
| Audit logging | Tracks sudo, auth, SSH, user/group changes |
| AppArmor | Mandatory access control (verified/enabled) |
| Auto-updates | Security patches applied daily via unattended-upgrades |
| Timezone | UTC (consistent logs) |
| Swap | 2GB swap file (prevents OOM kills) |
| DNS | Quad9 (9.9.9.9) with DNS-over-TLS + DNSSEC + fallback |
| Docker | Log rotation (10MB max, 3 files) |
- Password auth stays enabled until you confirm SSH key works
- Port 22 stays open until you confirm custom port works
- Won't auto-delete user if you're logged in as that user
- Fail2Ban configured for custom SSH port
SSH: ssh your-user@your-ip -p YOUR_PORT
Dokploy: http://your-ip:3000
After reconnecting with your new user, run the cleanup script:
./cleanup.shThis will safely remove the default ubuntu user and its home directory.
After configuring SSL in Dokploy, block external access to port 3000:
sudo iptables -I DOCKER-USER -p tcp --dport 3000 -j DROP
sudo iptables -I DOCKER-USER -i lo -p tcp --dport 3000 -j ACCEPT- Fresh Ubuntu 24.04 LTS VPS
- User with sudo privileges
- SSH public key ready
MIT