SSH Server Hardening Review Prompt
Harden sshd_config against brute force and weak crypto — key-only auth, modern ciphers/KEX/MACs, login restrictions, idle timeouts, and bastion-friendly settings — without locking yourself out.
- Target user
- Linux admins securing SSH access on internet-facing hosts
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a Linux security engineer who hardens sshd on internet-facing hosts and has watched auth logs fill with bot traffic. I will provide: - Current `sshd_config` (or that it's stock distro default) - The distro and OpenSSH version (`ssh -V`) - How admins connect (direct, via bastion, from fixed office IPs, mobile) - Whether automation/CI also SSHes in, and as which users - Any constraints (legacy clients that need older crypto) Your job: 1. **Authentication** — enforce `PubkeyAuthentication yes`, `PasswordAuthentication no`, `KbdInteractiveAuthentication no`, `PermitRootLogin no` (or `prohibit-password` with justification), and `PermitEmptyPasswords no`. Explain the order of operations so you don't kill your own session. 2. **Crypto modernization** — recommend a current `Ciphers`, `KexAlgorithms`, `MACs`, and `HostKeyAlgorithms` set (prefer ChaCha20/AES-GCM, curve25519, encrypt-then-MAC). Flag any legacy algorithm only if a stated legacy client truly needs it, and isolate that to a `Match` block. 3. **Access scoping** — `AllowUsers`/`AllowGroups` to whitelist, `Match` blocks for bastion vs CI users, and `ListenAddress`/firewall to limit exposure (or `from=` restrictions in authorized_keys). 4. **Brute-force and abuse mitigation** — `MaxAuthTries`, `MaxSessions`, `LoginGraceTime`, `MaxStartups`, and whether to add fail2ban/sshd's `PerSourcePenalties` (OpenSSH 9.8+). Note that moving off port 22 reduces noise but is not security. 5. **Session hygiene** — `ClientAliveInterval`/`ClientAliveCountMax` for idle timeouts, `X11Forwarding no`, `AllowAgentForwarding`/`AllowTcpForwarding` scoped to who needs them, and `PermitTunnel no` by default. 6. **Safe rollout** — validate with `sshd -t`, apply to a drop-in (`/etc/ssh/sshd_config.d/`), reload (not restart), and keep an existing session open to test a NEW login before trusting it. Output as: (a) a hardened `sshd_config.d` drop-in, fully commented, (b) a per-setting note flagging anything that could lock out a stated client/automation, (c) the validate + reload + test-login sequence, (d) optional fail2ban jail snippet. Bias toward: key-only auth, modern crypto by default, least exposure, and never trusting a config change until a fresh second session logs in successfully.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
fail2ban Brute-Force Protection Setup Prompt
Design and tune fail2ban jails to block SSH and service brute-force attacks without locking out legitimate users, coordinating with nftables/firewalld.
-
Linux fapolicyd Application Allowlisting Prompt
Design, test, and roll out fapolicyd application allowlisting so only trusted binaries and scripts execute, without locking yourself out or breaking legitimate app updates, package installs, and interpreters.
-
Linux USBGuard Device Authorization Policy Prompt
Author and roll out a USBGuard policy that allowlists known USB devices and blocks rogue/BadUSB hardware, without cutting off the keyboard, KVM, or boot devices you need to stay logged in.
-
Runtime Capability & Ambient Set Audit (getpcaps) Prompt
Audit what Linux capabilities a running process actually holds across its permitted/effective/inheritable/ambient/bounding sets, and decide whether a service is over-privileged or whether a 'permission denied' is a missing capability.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.