SSH Configuration Generator
Hardening a Linux server usually starts with /etc/ssh/sshd_config — and that file is
where most people either give up or lock themselves out. This generator builds a clean, commented
sshd_config starting point for the security requirements that actually matter on a public
server: key-only authentication instead of passwords, root login restricted to keys (or disabled
outright), forwarding features turned off unless you need them, sane login grace periods and auth
attempt limits, and a modern key-exchange/cipher list. Pick a preset, adjust the handful of directives
that matter, and you get a copy-ready config plus the install commands to drop it in as a drop-in file
under /etc/ssh/sshd_config.d/. The validation panel explains every risky choice in plain
English — including the two Ubuntu traps that silently undo your work: 50-cloud-init.conf
overriding your settings, and 24.04’s socket activation ignoring a changed Port. Already
have a config? Paste it in and the parser fills the form back in. Everything runs in your browser.
sshd_config are processed locally and never sent to a
server — so you can safely build a config for a machine that holds private data.
1 · Starting point
Pick a preset to fill the form with a working baseline. Choosing a preset replaces the current values — everything stays editable afterwards.
2 · Access & authentication
3 · Limits, forwarding & logging
4 · Import an existing sshd_config
Paste your current /etc/ssh/sshd_config (or a file from /etc/ssh/sshd_config.d/) and the known directives are mapped back into the form. Unknown lines, Match blocks and Include statements are kept in the extra-directives box so nothing is lost. Parsing happens in your browser.
5 · Your sshd_config
How it works
- Start from a preset. Each preset is a coherent set of directives — not just one switched-off feature. The hardened baseline matches Ubuntu’s intent (keys only, no root password login) while closing the forwarding features Ubuntu leaves open.
- Adjust the directives that matter. The form covers the settings that change your attack surface: port, root login, password vs key authentication, allow/deny lists, auth attempts, session limits and forwarding. Everything else stays at the daemon’s safe default.
- Read the findings. Every combination is checked for the ways a config actually bites: a combination that leaves no working auth method (instant lockout), password auth left on,
KbdInteractiveAuthenticationquietly re-enabling PAM passwords, tunnel forwarding on a public box, or an allow-list that names root. - Install as a drop-in file. The generated block goes in
/etc/ssh/sshd_config.d/10-hardening.conf, which is included from the top of the main config. Validate withsshd -t, reload withsystemctl reload ssh, then confirm what the daemon actually resolved withsshd -T. - Verify, don’t assume.
sshd_configuses first value wins, and Ubuntu’s cloud-init writes50-cloud-init.confwithPasswordAuthentication yes. A60-file loses to it; a10-file wins. The install block below includes the one-line check that proves the effective value.
Directive reference
| Directive | What it controls | Why it matters |
|---|---|---|
| PermitRootLogin | Whether root may authenticate, and with what. | yes exposes the highest-value account to password guessing; prohibit-password or no removes it. |
| PasswordAuthentication | Whether an account password can authenticate. | The single biggest source of successful SSH breaches. Keys cannot be guessed. |
| KbdInteractiveAuthentication | PAM interactive prompts (including password via PAM). | On many distros this is a second door to password login, so disabling one without the other achieves nothing. |
| PubkeyAuthentication | Public-key authentication. | Turn this off while password auth is also off and nobody can log in at all. |
| AllowUsers / AllowGroups | An allow-list of accounts or groups. | Without one, every system account with a shell is reachable. Group-based lists survive staff changes better. |
| MaxAuthTries | Failed auth attempts per connection. | Lower values cut brute-force throughput per connection. Ubuntu default is 6. |
| LoginGraceTime | Seconds allowed to complete authentication. | Un-authenticated connections tie up daemon slots; a short grace period frees them. |
| MaxStartups | Concurrent unauthenticated connections (start:rate:full). | Caps connection-flooding; dropping starts at 10 is a sane default. |
| ClientAliveInterval | Idle keepalive interval. | Clears dead sessions so abandoned shells stop holding an authorised channel. |
| AllowTcpForwarding | SSH port forwarding (tunnels). | Turns a compromised account into a network pivot. local keeps client tunnels without remote ones. |
| AllowAgentForwarding | Forwarding your local ssh-agent to the server. | Anyone with access to that server can use your loaded keys while you’re connected. |
| PermitTunnel | Layer-2/3 VPN tunnels over SSH. | A full network path in; leave it off unless you built it deliberately. |
| X11Forwarding | X11 display forwarding. | Legacy GUI path with a long history of bugs; Ubuntu ships it on for compatibility. |
| LogLevel | How much sshd logs. | VERBOSE records which key was used — the line you need when investigating an intrusion. |
| UsePAM | Whether sshd goes through PAM. | Needed for normal account/session handling on Ubuntu; turning it off breaks more than it hardens. |
Related tools
Suggested
Luke Keam | techgeek.biz