SSH hardening checklist for a VPS
A short, opinionated SSH hardening list — the changes that meaningfully reduce risk, in priority order. Plus the ones widely repeated but pointless.
High-impact (do these)
1. Disable password authentication
The single biggest win. SSH brute-force is constant background noise on every public IP. Keys are not brute-forceable in practice.
# /etc/ssh/sshd_config
PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no
KbdInteractiveAuthentication no
UsePAM yes
2. Disable root login
PermitRootLogin no
Root operations go through sudo from a named user. Audit trail in journalctl becomes useful.
3. Use a modern key type
Generate Ed25519 keys, not RSA 2048:
ssh-keygen -t ed25519 -a 100 -C "your-name@laptop"
Smaller, faster, harder to misuse. RSA 4096 is also fine; RSA 1024 / 2048 is past its sell-by date.
4. Restrict which users can SSH
# /etc/ssh/sshd_config
AllowUsers deploy backup
# or by group:
AllowGroups ssh-users
Stops a forgotten service account with a weak password from being a viable login path. Even with passwords disabled, defense in depth.
5. Cap concurrent connection attempts
MaxAuthTries 3
MaxSessions 4
LoginGraceTime 30
MaxStartups 10:30:60
Reduces the rate at which a scanner can probe; pairs well with fail2ban.
6. Disable forwarding you don't need
X11Forwarding no
AllowAgentForwarding no # only enable if you actively use SSH agent forwarding
AllowTcpForwarding no # only enable if you use SSH tunnels
7. Modern ciphers and MACs only
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
HostKeyAlgorithms ssh-ed25519,rsa-sha2-512,rsa-sha2-256
Drops legacy primitives nobody should still rely on. Some old jump-hosts and ancient automation may break — verify your client list first.
Reload and verify
sudo sshd -t # test config
sudo systemctl restart ssh
sudo ss -tnlp | grep sshd # confirm sshd is listening
Always test in a second window before closing your current SSH session.
Audit with ssh-audit
pip install --user ssh-audit
ssh-audit your-server-ip
It reports algorithms, vulnerabilities, and suggested removals. Aim for "no warnings on cryptographic algorithm choices."
Medium-impact (consider these)
SSH certificates instead of authorized_keys
For teams, sign user keys with a CA instead of distributing authorized_keys files. Revocation becomes trivial. Overhead pays back at 5+ servers / 3+ humans.
Bastion / jump host
One small hardened host with SSH open; everything else only accepts SSH from the bastion's IP. Reduces audit scope and surface area. Useful at 10+ servers.
2FA via PAM (TOTP)
Adds a second factor on top of keys. Friction is real; payoff depends on your threat model. We enable for shared-team servers, skip for personal VPSes.
Geo-restrict in iptables
If you only SSH from one or two countries, drop everything else. Substantially reduces scanning noise. Use xt_geoip or a CIDR-list iptables rule.
Low-impact (often overhyped)
Changing the SSH port
Moving to port 2222 removes 95% of automated scans from your log. It does not improve security — anyone running a port scan finds it instantly. We don't bother; cleaner logs aren't worth the muscle memory cost across many servers.
Port knocking
Hides SSH behind a sequence of "knocks." Effective at silencing logs, fiddly to operate, irrelevant to anyone who already has access to your IP. Skip.
Disabling IPv6 SSH
Modern IPv6 prefixes are sparse and unscanned; the noise level is much lower than IPv4. Leave it enabled.
Operational hygiene
- Rotate keys when a laptop changes hands. Easy: remove the public key from
~/.ssh/authorized_keys. - Use distinct keys per laptop / per role. One key per device, not one key reused across machines.
- Use a password manager or an SSH-agent passphrase. A bare unencrypted
id_ed25519on a laptop is one stolen laptop away from your servers. - Audit
journalctl -u sshperiodically.Accepted publickey for Xentries should match your team.
Need a VPS with clean SSH defaults?
Inferno's Ubuntu images ship modern OpenSSH (9.x) and accept keys at provisioning — no insecure default password. Pair with this hardening list.
What to do next
- Initial server setup — the rest of the baseline.
- Install fail2ban — throttle SSH probes.
- UFW setup.
- Docker hardening if you'll run containers.
Author: Riku Lehtinen — Tampere. Last reviewed: 2026-05-22 against OpenSSH 9.6 and current ssh-audit recommendations.