In 2024, the Volt Typhoon campaign pivoted through dozens of internet-facing Linux servers using nothing more exotic than valid SSH credentials and weak configurations. Same story in 2025 with the MOVEit-adjacent intrusions. Default OpenSSH settings are not production settings — and in 2026, leaving port 22 wide open with password auth enabled is an invitation.
Step 1: Audit What You’re Actually Exposing
Before changing anything, see what an attacker sees. Run ssh-audit — a tool that fingerprints your SSH server’s algorithms, ciphers, and known weaknesses — against your own host.
$ ssh-audit 192.0.2.47
# general
(gen) banner: SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
(gen) compatibility: OpenSSH 7.4+, Dropbear SSH 2018.76+
# key exchange algorithms
(kex) diffie-hellman-group14-sha256 -- [warn] 2048-bit modulus only
(kex) diffie-hellman-group-exchange-sha256 -- [info] using moduli <= 2048 bits
# encryption algorithms (ciphers)
(enc) aes128-ctr -- [warn] using weak cipher
(enc) chacha20-poly1305@openssh.com -- [info] available
# message authentication codes
(mac) hmac-sha1 -- [fail] using broken MAC algorithm
(mac) hmac-sha2-256 -- [info] available
# host-key algorithms
(key) ssh-rsa -- [fail] using deprecated algorithm
(key) ecdsa-sha2-nistp256 -- [warn] using a potentially backdoored curve
Three red flags right there: broken HMAC-SHA1, deprecated RSA host keys, and a NIST P-256 curve that security researchers have flagged for years. An attacker doing recon sees the same output in seconds.
The fix is surgical. Open /etc/ssh/sshd_config and lock down algorithms explicitly:
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
HostKeyAlgorithms ssh-ed25519,rsa-sha2-512
Reload with sudo systemctl reload sshd, then run ssh-audit again. You want zero [fail] lines before anything hits production.
Step 2: Lock Down sshd_config — The Settings That Actually Matter
Most guides list every option. Here are the ones that stop real attacks on servers like prod-web-01.internal running as ubuntu:
# /etc/ssh/sshd_config — production hardened
Port 2222
AddressFamily inet
ListenAddress 192.0.2.47
PermitRootLogin no
PasswordAuthentication no
ChallengeResponseAuthentication no
PermitEmptyPasswords no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
AllowUsers deploy@192.0.2.0/24 ansible@192.0.2.10
MaxAuthTries 3
LoginGraceTime 20
ClientAliveInterval 300
ClientAliveCountMax 2
X11Forwarding no
AllowAgentForwarding no
AllowTcpForwarding no
PermitTunnel no
Banner /etc/ssh/banner.txt
LogLevel VERBOSE
A few of these deserve a direct explanation. AllowUsers with IP restriction means that even if attacker deploy credentials leak, they cannot connect from outside your management subnet. MaxAuthTries 3 cuts brute-force attempts short before fail2ban even kicks in. AllowTcpForwarding no prevents an attacker who lands a session from tunneling deeper into your internal network — a lateral movement technique Volt Typhoon used extensively.
Moving to port 2222 is not security through obscurity as your only defense — it eliminates roughly 95% of automated scanner noise, which keeps your logs clean and meaningful.
Step 3: Enforce Key Quality and Monitor Active Sessions
Weak keys are as bad as passwords. Check every authorized key on the box right now:
$ for user in $(cut -d: -f1 /etc/passwd); do
keyfile="/home/$user/.ssh/authorized_keys";
if [ -f "$keyfile" ]; then
echo "=== $user ===";
ssh-keygen -l -f "$keyfile";
fi;
done
=== deploy ===
2048 SHA256:xK9mPqR3nLvZ... deploy@laptop-old (RSA)
256 SHA256:aB7wYtU2cFqN... ansible@mgmt-01 (ED25519)
=== ubuntu ===
1024 SHA256:zZ1kQpM8dXsW... ubuntu@legacy-box (DSA)
That 1024-bit DSA key for ubuntu is catastrophically weak — DSA-1024 can be broken. That 2048-bit RSA key for deploy is acceptable but aging. Remove both and replace them with Ed25519 keys: ssh-keygen -t ed25519 -C "deploy@prod-web-01 2026". Ed25519 is fast, small, and has no known weaknesses.
Then watch who is actually connected. Pair this with auditd to log every SSH login to /var/log/audit/audit.log:
$ sudo ss -tnp | grep sshd
STATE Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 192.0.2.47:2222 192.0.2.10:54312 users:(("sshd",pid=3847))
One active session from 192.0.2.10 — your Ansible controller. That is expected. An unfamiliar IP here, especially one outside your AllowUsers subnet, means your investigation starts immediately.
What To Do Right Now
Pick your highest-exposure production server and run ssh-audit <your-server-ip> against it today. Install it in seconds with pip install ssh-audit. Count every [fail] and [warn] line in the output. That number is your actual attack surface — not a theoretical risk score. Fix the [fail] items in sshd_config tonight, test with a second session before closing your first, and schedule the [warn] items for this week. Hardening SSH takes under an hour. Getting evicted from your own server takes much longer.
