DEV Community

Cover image for Securing a VPS in 2026: A No-Nonsense Hardening Guide
Pushpum Vats
Pushpum Vats

Posted on Edited on Originally published at zyvop.com AI-assisted

Securing a VPS in 2026: A No-Nonsense Hardening Guide

Ranked by impact: what to do in the first 30 minutes, the first week, and forever after.

A default VPS is not a secure VPS. Within minutes of getting a public IP, bots start trying SSH passwords, probing open ports, and looking for outdated software. Most compromises are not clever; they are a weak login, an exposed database, or an unpatched service.

This guide is ordered by impact:

  • Tier 1 (about 30 minutes): do it before the server touches production traffic.

  • Tier 2 (first week): closes the next most common holes.

  • Tier 3 (if it applies to your stack): TLS, Docker, team access.

  • Tier 4 (ongoing): monitoring, maintenance, and what to do if it goes wrong.

It targets Ubuntu 24.04 LTS and Debian 12/13. Commands are the same on newer releases unless noted. A few sections include traps that silently undo your work; those are flagged.


Tier 1 — Before Production

1. Lock the account that controls the server

Your SSH config does not matter if someone takes over the account that owns the server. The provider panel can reset the root password, mount a rescue disk, and snapshot your data.

  • Turn on 2FA for your VPS provider, domain registrar, and DNS provider. Prefer a passkey or hardware key over SMS.

  • A hijacked DNS account lets an attacker issue valid TLS certificates and intercept mail for your domain.

  • Use scoped API tokens, never your master credentials, and keep them out of repos.

2. Create a sudo user and switch to SSH keys

# On the server, as root
adduser deploy
usermod -aG sudo deploy

# On your own machine: generate a modern key (Ed25519, not RSA)
ssh-keygen -t ed25519 -a 100 -C "you@yourdomain.com"
ssh-copy-id -i ~/.ssh/id_ed25519.pub deploy@your-server-ip
Enter fullscreen mode Exit fullscreen mode

Open a new terminal and confirm ssh deploy@your-server-ip works and sudo -v succeeds. Only then continue. Once you've confirmed it, lock root's password: sudo passwd -l root.

3. Harden sshd (and dodge three traps)

Create /etc/ssh/sshd_config.d/00-hardening.conf:

PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
PermitEmptyPasswords no
MaxAuthTries 3
LoginGraceTime 30
AllowUsers deploy
X11Forwarding no
AllowAgentForwarding no
ClientAliveInterval 300
ClientAliveCountMax 2
# AllowTcpForwarding no   # also good, but breaks SSH tunnels, VS Code Remote, DB tunnels
Enter fullscreen mode Exit fullscreen mode

Trap 1: the first value wins, and cloud-init can re-enable passwords. sshd uses the first value it reads for each setting, and files in sshd_config.d/ are read before the main file. On many cloud images, 50-cloud-init.conf sets PasswordAuthentication yes, which silently beats the no in your main sshd_config. Naming your file 00-... makes it win. Always check the effective config instead of assuming:

sudo sshd -T | grep -E 'passwordauthentication|permitrootlogin|allowusers'
sudo grep -ri passwordauthentication /etc/ssh/sshd_config /etc/ssh/sshd_config.d/
Enter fullscreen mode Exit fullscreen mode

Trap 2: validate before you apply, and keep a session open.

sudo sshd -t && sudo systemctl reload ssh
Enter fullscreen mode Exit fullscreen mode

sshd -t catches typos and unsupported options without touching the running service. Reload keeps existing sessions alive. Test a fresh login from a second terminal before closing the first.

Trap 3: on Ubuntu 24.04, changing the port needs an extra step. Ubuntu 24.04 starts sshd through socket activation, and editing sshd_config alone does not move the listening port. Put the port in a drop-in, then reload systemd and restart the socket:

echo "Port 2233" | sudo tee /etc/ssh/sshd_config.d/10-port.conf
sudo systemctl daemon-reload
sudo systemctl restart ssh.socket
Enter fullscreen mode Exit fullscreen mode

Open the new port in your firewall first, confirm you can log in on it from a second terminal, and only then remove the old rule. Changing the port stops scanner noise in your logs, not a targeted attacker, so treat it as optional.

Optional: tighten the crypto (check your OpenSSH version first)

Modern OpenSSH defaults are already good. This step removes legacy fallbacks, at the cost of breaking very old clients. Post-quantum hybrid key exchange protects today's traffic against "harvest now, decrypt later" recording. OpenSSH 10.0 made mlkem768x25519-sha256 the default key exchange, but Ubuntu 24.04 (OpenSSH 9.6) and Debian 12 (9.2) predate it and use sntrup761x25519-sha512@openssh.com, which is also a hybrid.

ssh -V                                   # your OpenSSH version
ssh -Q kex | grep -E 'mlkem|sntrup'      # what your build supports
Enter fullscreen mode Exit fullscreen mode

For Ubuntu 24.04 / Debian 12 (OpenSSH 9.x), add to your drop-in:

KexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
Enter fullscreen mode Exit fullscreen mode

For OpenSSH 10.0+ (for example Debian 13), you can pin the new default instead:

KexAlgorithms mlkem768x25519-sha256,curve25519-sha256
Enter fullscreen mode Exit fullscreen mode

An algorithm name your version doesn't know makes sshd reject the whole file, which is exactly why you run sshd -t first. Then audit the result from outside with ssh-audit: ssh-audit your-server-ip.

4. Firewall: default deny, then allow

sudo apt install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw limit OpenSSH        # allow SSH, rate-limit repeated connection attempts
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose
Enter fullscreen mode Exit fullscreen mode
  • Allow SSH before enabling, or you lock yourself out. If you moved the SSH port, allow that port instead of OpenSSH.

  • Have a static IP or VPN? Replace the SSH rule with sudo ufw allow from 203.0.113.7 to any port 22 proto tcp. A port that only you can reach cannot be brute-forced by anyone else.

  • Check IPv6. Make sure IPV6=yes is set in /etc/default/ufw, so IPv6 is not an open back door beside your IPv4 rules.

  • Add the provider's cloud firewall as a second layer. It is usually free and applies before traffic reaches the box. Mirror the same rules.

Running Docker? Read this now. Docker publishes ports by writing its own iptables rules, and traffic to published ports is forwarded in a way UFW's rules never see. -p 8080:80 is reachable from the whole internet even with ufw deny 8080. The simplest fix is to bind published ports to localhost and put a reverse proxy in front:

ports:
  - "127.0.0.1:8080:80"

Verify with ss -tlnp | grep 8080, which must show 127.0.0.1, not 0.0.0.0. More in the Docker section below.

5. Know what's listening

This is the cheapest high-value check there is.

sudo ss -tulpn
Enter fullscreen mode Exit fullscreen mode

Anything bound to 0.0.0.0 or [::] other than SSH and your web server is suspect. Fix it by binding that service to 127.0.0.1, or by removing it. For the view an attacker has, scan your own server from another machine: nmap -Pn -p- your-server-ip. Do this only on servers you own.

6. Patch now, then automate

The image you were given may already be out of date.

sudo apt update && sudo apt full-upgrade -y && sudo reboot
sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
Enter fullscreen mode Exit fullscreen mode

In /etc/apt/apt.conf.d/50unattended-upgrades:

Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
Enter fullscreen mode Exit fullscreen mode
  • The defaults on Ubuntu and Debian cover security updates only. That is what you want on a server, so leave it.

  • Don't blacklist the kernel; kernel fixes are security fixes. If you can't tolerate a 04:00 reboot, leave Automatic-Reboot off and check for /var/run/reboot-required weekly.

  • Dry-run after any edit with sudo unattended-upgrade --dry-run -v, and read /var/log/unattended-upgrades/ to confirm it runs.

  • Skip the Mail options unless the server has a working mail transfer agent; otherwise the alerts go nowhere.

  • Kernel live patching is available through Ubuntu Pro (free tier for personal use; check the current terms). It works only where your VPS runs its own kernel, not on container-style VPS plans.

  • unattended-upgrades does not patch what you installed outside apt: Docker images, npm/pip packages, CMS plugins. Those need their own update routine.

Why bother: the 2024 OpenSSH "regreSSHion" bug (CVE-2024-6387) was an unauthenticated remote code execution flaw in the SSH server itself. Machines that patched automatically needed no action.

7. Backups that survive a compromise

Hardening lowers the odds; it doesn't make you immune, and it does nothing for hardware failure or a bad rm -rf. Your backups need three properties: encrypted, off-site, and out of reach of the server they protect. An attacker with root will delete any backup the server can delete.

# Example with restic (any S3-compatible storage works)
export RESTIC_REPOSITORY=s3:s3.amazonaws.com/your-backup-bucket
export RESTIC_PASSWORD_FILE=/root/.restic-pass   # store a copy elsewhere: lose it, lose the backups
export AWS_ACCESS_KEY_ID=...  AWS_SECRET_ACCESS_KEY=...

restic init
restic backup /etc /home /var/www
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune
Enter fullscreen mode Exit fullscreen mode
  • Give the backup credentials write-only access, or enable object lock or versioning on the bucket, so a compromised server cannot erase history.

  • Don't back up live database files. Dump them first (pg_dump, mysqldump --single-transaction) and back up the dump.

  • Provider snapshots help, but they sit in the same account as the server. Keep an independent copy too.

  • Schedule it with a systemd timer or cron, then do a restore drill. A backup you've never restored isn't a backup.


Tier 2 — First Week

8. Ban repeat offenders: Fail2Ban

sudo apt install fail2ban python3-systemd
Enter fullscreen mode Exit fullscreen mode

Put overrides in /etc/fail2ban/jail.d/local.conf rather than copying jail.conf, so package upgrades don't fight your edits:

[DEFAULT]
backend  = systemd
bantime  = 1h
findtime = 10m
maxretry = 3
bantime.increment = true
bantime.maxtime   = 1w
ignoreip = 127.0.0.1/8 ::1 YOUR.HOME.IP

[sshd]
enabled = true
# port = 2233   # only if you changed the SSH port
Enter fullscreen mode Exit fullscreen mode
sudo systemctl enable --now fail2ban
sudo fail2ban-client status sshd
Enter fullscreen mode Exit fullscreen mode

With key-only SSH, Fail2Ban mostly cuts log noise and CPU load; your SSH config is what actually protects you. It earns its keep on web logins and other services. For more than one server, CrowdSec shares threat intelligence across its network and has bouncers for firewalls and web servers. The two coexist fine if they don't manage the same log source.

9. Databases and caches: never public

Exposed databases and Redis instances are among the most common real-world breaches.

# MySQL / MariaDB
[mysqld]
bind-address = 127.0.0.1
Enter fullscreen mode Exit fullscreen mode
# PostgreSQL: postgresql.conf
listen_addresses = 'localhost'

# Redis: redis.conf
bind 127.0.0.1 ::1
protected-mode yes
Enter fullscreen mode Exit fullscreen mode
-- Least-privilege application user (MySQL example)
CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'long-random-password';
GRANT SELECT, INSERT, UPDATE, DELETE ON app_db.* TO 'app_user'@'localhost';
Enter fullscreen mode Exit fullscreen mode

Run mysql_secure_installation on MySQL/MariaDB to remove anonymous users and remote root. Applications should never connect as a superuser. If a second server genuinely needs access, allow its IP in the firewall for that one port. Don't bind to 0.0.0.0.

10. Hardware-backed SSH keys (FIDO2)

For admin access to anything important, keep the private key on a hardware token (YubiKey, SoloKey, etc.), so a stolen laptop alone can't be used to log in:

ssh-keygen -t ed25519-sk -O resident -O verify-required -C "you@yourdomain.com"
Enter fullscreen mode Exit fullscreen mode

This needs OpenSSH 8.2+ on both ends (8.4+ for verify-required, which demands the token's PIN) and a FIDO2 token. Enroll two tokens and keep your provider console as break-glass access. A lost token is otherwise a lost server.

11. Mandatory access control and file permissions

sudo aa-status        # AppArmor should show profiles in enforce mode
                      # (not installed? sudo apt install apparmor apparmor-utils)

chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
chmod 600 /path/to/your/app/.env       # secrets are never world-readable

sudo find / -xdev -type f -perm -0002 2>/dev/null    # world-writable files
sudo find / -xdev -type f -perm /6000 2>/dev/null    # SUID/SGID: investigate unfamiliar ones
Enter fullscreen mode Exit fullscreen mode

On RHEL-based systems, use sestatus and keep SELinux in Enforcing mode. When it blocks something, fix the policy; don't set it to Permissive.

12. Kernel network hardening

Create /etc/sysctl.d/99-hardening.conf:

net.ipv4.tcp_syncookies = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_source_route = 0
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
Enter fullscreen mode Exit fullscreen mode
sudo sysctl --system
Enter fullscreen mode Exit fullscreen mode

Treat this as hygiene, not a major defense: many of these are already defaults on current Ubuntu and Debian, so check before assuming you've gained much. Strict rp_filter = 1 can break asymmetric routing; if you run WireGuard or Tailscale with policy routing, use 2 (loose). Don't set net.ipv4.ip_forward = 0, because Docker needs it.


Tier 3 — If It Applies to Your Stack

13. TLS and web server hardening

Use Let's Encrypt with automatic renewal:

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
sudo certbot renew --dry-run
sudo systemctl list-timers | grep certbot     # confirm the renewal timer exists
Enter fullscreen mode Exit fullscreen mode

Certbot's nginx plugin already writes a sane TLS baseline. These extras go in the http { } block:

server_tokens off;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers off;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;

limit_req_zone $binary_remote_addr zone=perip:10m rate=10r/s;
Enter fullscreen mode Exit fullscreen mode

This is a trimmed ECDHE-only version of Mozilla's Intermediate profile. Mozilla's generator is the source of truth for the current lists, and you can drop to TLS 1.3 only if you don't need to support older clients. Then, in your server { } block:

add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
add_header X-Frame-Options SAMEORIGIN always;

location /login {
    limit_req zone=perip burst=10 nodelay;   # rate-limit credential guessing
    # ... your proxy_pass / fastcgi config
}
Enter fullscreen mode Exit fullscreen mode
  • Don't enable ssl_stapling with Let's Encrypt certificates. Let's Encrypt stopped putting OCSP URLs in certificates in May 2025 and turned its OCSP responders off in August 2025. nginx just logs "ssl_stapling" ignored, no OCSP responder URL in the certificate. If you see those directives in old configs or Certbot's options-ssl-nginx.conf, remove them.

  • Roll out HSTS carefully. Start with max-age=300 while testing and raise it once everything works over HTTPS. Add preload only if every subdomain will always serve HTTPS; removal from browser preload lists takes months.

  • Certificate lifetimes are shrinking. The CA/Browser Forum cap dropped to 200 days on March 15, 2026, with 47 days planned by 2029. Let's Encrypt already issues 90-day certificates, so you're fine as long as the renewal timer works, which is why the dry-run above matters. The change mostly hurts people who buy and install certificates by hand.

  • Grade the result with SSL Labs or testssl.sh.

14. Docker hardening

  • Bind published ports to localhost (127.0.0.1:8080:80) and put a reverse proxy in front. This is the fix for the UFW bypass above.

  • If you must expose a port with UFW in the loop, the alternative is a DOCKER-USER chain setup in /etc/ufw/after.rules plus ufw route allow rules. It works but is fiddly: container IPs can change on restart. Setting "iptables": false in daemon.json also works, but it breaks container networking and port publishing, so it's the most disruptive option.

  • Run as non-root, drop capabilities, and make the filesystem read-only:

services:
  app:
    image: your-app:1.2.3          # pin versions; never :latest in production
    user: "10001:10001"
    read_only: true
    tmpfs: [/tmp]
    cap_drop: [ALL]
    security_opt: ["no-new-privileges:true"]
    ports:
      - "127.0.0.1:8080:80"
Enter fullscreen mode Exit fullscreen mode
  • Never use --privileged. Never mount /var/run/docker.sock into a container unless orchestration is its whole job: it is root-equivalent access to the host.

  • Daemon-level options in /etc/docker/daemon.json:

{
  "icc": false,
  "no-new-privileges": true,
  "userns-remap": "default"
}
Enter fullscreen mode Exit fullscreen mode

userns-remap maps container root to an unprivileged host user, but can break bind-mount permissions, so test it. icc: false disables unrestricted traffic between containers on the default bridge.

  • Rebuild images on a schedule so you aren't shipping stale CVEs, and scan before deploying: trivy image your-app:1.2.3.

  • Run Fail2Ban on the host watching host logs, not inside a container.

15. Systemd sandboxing for services outside Docker

If an app runs directly as a systemd unit, you can get much of the isolation of a container for free. Run it as a dedicated unprivileged user and add:

[Service]
User=myapp
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
ReadWritePaths=/var/lib/myapp
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
CapabilityBoundingSet=
MemoryMax=768M
Enter fullscreen mode Exit fullscreen mode

This limits the blast radius: a compromised service can't read arbitrary paths, escalate privileges, or exhaust the host's memory. An empty CapabilityBoundingSet also blocks binding ports below 1024; if the service needs that, allow CAP_NET_BIND_SERVICE. Test after each change. Score a unit's exposure with:

systemd-analyze security myapp.service
Enter fullscreen mode Exit fullscreen mode

16. SSH for teams: certificates, 2FA, or no public port

A single admin is fine with one key. Once several people need access, static keys scattered across authorized_keys files become a liability, because nobody remembers to remove them when someone leaves.

SSH certificates replace that with short-lived credentials issued from one CA:

# One time: create the CA keypair. Protect ssh-user-ca with a passphrase and keep it offline.
ssh-keygen -t ed25519 -f ssh-user-ca -C "internal user CA"

# Sign a user's public key: valid 24 hours, allowed to log in as "deploy"
ssh-keygen -s ssh-user-ca -I alice-daily -n deploy -V +24h alice_id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

Copy ssh-user-ca.pub to each server as /etc/ssh/ca.pub, then add this to your sshd drop-in:

TrustedUserCAKeys /etc/ssh/ca.pub
Enter fullscreen mode Exit fullscreen mode

Revoking someone is now "stop signing for them", not a hunt through every server.

TOTP 2FA is the lower-cost option when hardware keys aren't practical:

sudo apt install libpam-google-authenticator
google-authenticator        # run as the user; store the backup codes safely
Enter fullscreen mode Exit fullscreen mode
# /etc/pam.d/sshd: comment out "@include common-auth", then add:
auth required pam_google_authenticator.so
Enter fullscreen mode Exit fullscreen mode
# In your sshd drop-in, CHANGE the earlier KbdInteractiveAuthentication line to yes,
# since a second, conflicting line is ignored (first value wins), and add:
UsePAM yes
AuthenticationMethods publickey,keyboard-interactive
Enter fullscreen mode Exit fullscreen mode

That demands a valid key and a TOTP code. It is not phishing-resistant like FIDO2, but it is a real step up from key-only. Keep a root session open while testing.

No public SSH port at all is worth considering once you manage more than a couple of servers. Tailscale SSH authenticates sessions over a WireGuard mesh with no inbound port, and cloud-native options like AWS SSM Session Manager do the same with IAM.

17. Disk encryption: know what it does and doesn't buy you

Full-disk encryption (LUKS) protects data at rest: stolen or recycled drives, leaked snapshots. It does not protect against someone with access while the server is running, and a remote-unlocked root volume adds operational friction. Best enabled at install time; encrypting an existing root filesystem in place is rarely worth it. For most VPS setups, the practical wins are encrypted backups (restic and borg already do this) and an encrypted data partition if you hold sensitive data.


Tier 4 — Ongoing

18. Auditing and monitoring

sudo apt install auditd lynis

sudo tee /etc/audit/rules.d/99-hardening.rules <<'EOF'
-w /etc/passwd -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /etc/sudoers -p wa -k sudoers
-w /etc/sudoers.d/ -p wa -k sudoers
-w /etc/ssh/sshd_config -p wa -k sshd_config
-w /etc/ssh/sshd_config.d/ -p wa -k sshd_config
-w /home/deploy/.ssh/authorized_keys -p wa -k ssh_keys
-w /root/.ssh/authorized_keys -p wa -k ssh_keys
EOF
sudo augenrules --load

sudo ausearch -k ssh_keys --start today   # review hits
sudo lynis audit system                   # full posture audit with prioritized suggestions
Enter fullscreen mode Exit fullscreen mode
  • Logs stored only on the server are logs an intruder can erase. Ship them off-box (a syslog host, Loki, or a hosted log service) and add an external uptime monitor so you notice outages.

  • Rootkit scanners (rkhunter, chkrootkit) are noisy and low-signal on a patched box. Skip them unless a compliance requirement says otherwise.

  • Antivirus isn't a meaningful control on a Linux server. Patching, least privilege, and reading logs beat it.

19. If you think you've been compromised

Don't try to clean it. You can't prove a cleaned machine is clean. Rebuild.

  1. Isolate: in the provider's firewall, deny everything except your own IP.

  2. Preserve evidence: take a provider snapshot and copy the logs (journalctl, /var/log/auth.log, last -a, lastb) before you wipe anything.

  3. Rotate everything the server could reach: SSH keys, API tokens, database passwords, .env secrets, TLS private keys, and the provider API keys.

  4. Rebuild from a clean image and restore data from a backup taken before the incident.

  5. Find the way in and close it before going live again, then re-run this guide from the top.

20. Maintenance cadence

Configuration drifts. Put this on a recurring calendar block:

  • Weekly: review Fail2Ban ban logs, confirm unattended-upgrades ran, check for /var/run/reboot-required, glance at disk usage (df -h).

  • Monthly: audit user accounts and sudoers, re-run sudo ss -tulpn and look for new listeners, run lynis audit system and act on new warnings.

  • Quarterly: rotate SSH keys and long-lived credentials, re-run ssh-audit and a TLS scan, update third-party software (images, packages, plugins), and test a full backup restore.


Quick Checklist

Tier 1: before production

  • 2FA on the provider, registrar, and DNS accounts

  • Sudo user created, key-based SSH works, root locked

  • Hardening drop-in named 00-...; sshd -T shows password auth off

  • Firewall default-deny, IPv6 handled, provider firewall mirrors it

  • ss -tulpn reviewed: nothing public except SSH and web

  • System updated; unattended-upgrades verified with --dry-run

  • Encrypted, off-site backups the server can't delete, restore-tested

Tier 2: first week

  • Fail2Ban active, your own IP in ignoreip

  • Databases and Redis bound to localhost; app users least-privilege

  • Hardware-backed SSH keys for admins (two tokens enrolled)

  • AppArmor/SELinux enforcing; secrets are 600

  • sysctl hardening applied (and checked against defaults)

Tier 3: if applicable

  • TLS configured, no ssl_stapling on Let's Encrypt, renewal dry-run passes

  • Docker ports bound to 127.0.0.1; containers non-root, no socket mount

  • systemd sandboxing on bare-metal services

  • SSH certificates or TOTP for multi-admin access

Tier 4: ongoing

  • auditd rules loaded, logs shipped off-box, uptime monitor on

  • Incident plan written down (isolate, preserve, rotate, rebuild)

  • Weekly, monthly, and quarterly cadence on the calendar

Run Tier 1 on every new server before it sees production traffic. The rest isn't optional so much as scheduled: security is a habit you keep paying into, not a setup you finish.


References


Published via ZyVOP — Write once in Markdown, auto-backup to GitHub, and syndicate to Dev.to, Medium & Hashnode in 1 click.

Top comments (0)