Home / Guides / SSH Hardening

SSH hardening the 8-minute minimum

Any public VPS gets brute-forced within minutes of going online. This is the baseline that stops it. Works on any Ubuntu/Debian server โ€” including ours.

1. Keys first (never lock yourself out)

# on YOUR computer:
ssh-keygen -t ed25519 -C "vps"
ssh-copy-id root@YOUR_SERVER_IP
ssh root@YOUR_SERVER_IP        # must log in WITHOUT password โ€” verify!

2. Kill password logins

sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
systemctl reload ssh
# keep this session open; test a NEW connection before closing it

3. Firewall + brute-force protection

apt install -y ufw fail2ban
ufw default deny incoming && ufw default allow outgoing
ufw allow OpenSSH && ufw enable
cat > /etc/fail2ban/jail.local <<'EOF'
[sshd]
enabled = true
maxretry = 5
bantime = 1h
EOF
systemctl enable --now fail2ban

4. Automatic security updates

apt install -y unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades   # choose Yes

That's the 80/20 of server security: keys, firewall, bans, patches. Want to skip step 1โ€“2? Our servers ship hardened by default โ€” see plans.

Related