Use it to harden or change the SSH server, or when a setting seems ignored.
sshd_config
sshd_config (/etc/ssh/sshd_config and drop-ins in sshd_config.d/) controls the SSH server: port, listen address, authentication methods, root login, allowed users, ciphers, forwarding and Match blocks.
1. sshd -T | grep -i <setting> — effective value.
2. Not what you set → earlier value in sshd_config.d/ or a Match block.
3. Edit, then sshd -t.
4. systemctl reload sshd.
5. Test login in a new session.
Include drop-ins and main file read → first value per option wins → Match blocks applied per connection
For SSH → sshd_config, continue with the first unproven Topic check: Run syntax validation before activation and record the exact files/Includes being parsed. If that boundary is healthy, advance to the adjacent check: Inspect effective settings for the target user/address context, including Match blocks. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
sshd_config/includes → parse validation → global + Match evaluation → daemon loaded policy → new connection → authentication/account checks → channel/subsystem policy → workload
Healthy evidence: syntax validates, expected Include/Match rules resolve for the target connection, daemon loads the state and a fresh connection behaves according to intended policy.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Run syntax validation before activation and record the exact files/Includes being parsed.
- Inspect effective settings for the target user/address context, including Match blocks.
- Verify listener, auth methods, forwarding, subsystem and session restrictions relevant to the use case.
- Reload/restart only as needed, then establish a new connection and repeat the original operation.
Verification chain. sshd_config/includes → parse validation → global + Match evaluation → daemon loaded policy → new connection → authentication/account checks → channel/subsystem policy → workload
Step 3 Specialized verification Verify boundary
Validate syntax, then query the effective configuration using the target user/address/host context where supported. Confirm the running listener, process generation and service logs. Perform a new SSH connection using the intended authentication method; an existing session shows little about new policy. For key/auth failures, increase client/server diagnostic detail without exposing secrets and identify the exact stage—transport, host key, user authentication, account policy or session setup.
Step 4 Commands Verify boundary
sshd -T | grep -iE 'permitrootlogin|passwordauthentication|pubkeyauthentication'
ls /etc/ssh/sshd_config.d/
Step 5 Failure modes and next checks Narrow the fault
Suspicious evidence: an Include or Match override changes the target user path, edited config is not loaded, auth/forwarding/subsystem policy differs by source context or syntax-only validation is treated as functional evidence.
Step 6 Special cases and limits Narrow the fault
Syntax success does not show a Match block yields the expected value, and a successful TCP connection does not show authentication. Existing sessions can survive restrictive configuration changes. Client configuration can choose a different username, key, proxy or hostname than expected. SELinux/AppArmor, file ownership and PAM/account policy can deny access even when sshd_config appears permissive. Separate daemon config, listener, authentication and post-auth session policy.
Step 7 Common mistakes Narrow the fault
- Settings in drop-ins overriding the main file unexpectedly (first match wins).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Drop-ins are read first, and the first value wins — a drop-in can override the main file. Check the effective result with sshd -T. Validate with sshd -t and reload with a second session open.
ssh -v user@host— client-side connection and authentication stepsjournalctl -u ssh -u sshd -e— server logsshd -T— effective server settingsss -ltnp | grep :22— sshd listening
ReferenceWhat it is1 section · depth on demand
Core model
Validate syntax, then derive effective configuration for the target user/source/host context. Separate global defaults from Match overrides and distinguish daemon reload from session behavior already established under older state.
ReferenceImportant terms & boundaries6 sections · depth on demand
What this shows and what it does not
A valid/effective sshd_config establishes intended daemon policy for a context, but it does not show client trust, credential possession, filesystem permissions or successful downstream workload execution.
sshd_config owns server policy syntax and effective Match behavior. sshd owns daemon runtime; Users/Permissions owns local account/file permissions; Firewall owns packet filtering.
In depth
sshd_config structure: first value, Match and Include
sshd_config looks like a simple list of settings, but two rules decide what actually applies. The sshd_config(5) manual page states them:
- First value wins: unless noted otherwise, the first value obtained for each keyword is used. A later line doesn't override an earlier one.
- Match blocks: a
Matchblock overrides global settings for connections that meet its criteria. If several matching blocks set the same keyword, only the first one counts. Only a subset of keywords is allowed inside Match.
Include loads further files, with globs allowed and relative paths resolving to /etc/ssh.
Match criteria
| Criterion | Example |
|---|---|
User | Match User backup |
Group | Match Group sftp-only |
Address | Match Address 10.99.0.0/24 |
Host | Match Host *.example.net (needs DNS) |
LocalPort | Match LocalPort 2222 |
all | Match all ends a conditional section |
Keywords often used inside Match (manual)
| Keyword | Typical use |
|---|---|
ChrootDirectory | Confine SFTP users to a directory |
ForceCommand | Run a fixed command, e.g. internal-sftp |
AllowTcpForwarding | Allow forwarding for a few users only |
PasswordAuthentication | Allow passwords from one management network |
AuthenticationMethods | Require MFA for some users |
A restricted SFTP group and a management exception
srv1$ sudo tee /etc/ssh/sshd_config.d/20-match.conf >/dev/null <<'EOF'
Match Group sftp-only
ChrootDirectory /srv/sftp/%u
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
Match Address 10.99.0.0/24
PasswordAuthentication yes
Match all
EOF
srv1$ sudo sshd -t
srv1$ sudo sshd -T -C user=upload1,host=x,addr=203.0.113.50 | grep -E "^(chrootdirectory|forcecommand|passwordauthentication)"
chrootdirectory /srv/sftp/%u
forcecommand internal-sftp
passwordauthentication no
srv1$ sudo stat -c '%a %U %n' /srv/sftp /srv/sftp/upload1
755 root /srv/sftp
755 root /srv/sftp/upload1
Chroot requirements
The chroot directory and every directory above it must be owned by root and not writable by others. Users therefore need a writable subdirectory inside it, such as /srv/sftp/upload1/incoming. A chroot that breaks this rule makes the login fail immediately after authentication.
Documented example, not captured output.
How it works at runtime
sshd_config is part of SSH → sshd_config. sshd_config defines OpenSSH server policy for listeners, host keys, authentication, account/session behavior, forwarding and subsystems, with Include and Match blocks producing connection-context-specific effective configuration.
Topic-specific state model. sshd_config defines OpenSSH server policy for listeners, host keys, authentication, account/session behavior, forwarding and subsystems, with Include and Match blocks producing connection-context-specific effective configuration.
Technical metadata. Client host/distribution/OpenSSH version, server host/distribution/OpenSSH version, timestamp, destination name/address/port, source address, username, ssh_config Host/Match/Include resolution, proxy/jump path, negotiated KEX/host-key/cipher/MAC where relevant, server host-key fingerprint, known_hosts source, authentication method, client identity fingerprint/agent source, authorized-key source/options, sshd_config Include/Match/effective policy, PAM/account result, session type, PTY/command/subsystem, local/remote/dynamic forward endpoints, server PID/unit/listener, remote process/exit status, source/destination file path and hash where relevant, client/server logs and original workload result.
Interpretation rule. - sshd -t success ≠ intended semantics or secure policy.
- Global directive ≠ effective value after Match block evaluation.
- File edited ≠ daemon reloaded or new connection using that state.
- Authentication enabled ≠ the target account/method is authorized by all effective policy layers.
Specialized mechanics
sshd builds an effective server configuration from global directives, included files and conditional Match blocks evaluated for a connection. Some settings are connection-specific because user, group, host, address and local-address criteria can change the effective policy. The daemon’s running configuration is the state loaded by the current process generation; editing a file does not retroactively alter established sessions or necessarily affect a daemon until reload/restart.
Quick reference
Server configuration (/etc/ssh/sshd_config, drop-ins in /etc/ssh/sshd_config.d/*.conf included early — first value wins):
Port 22
ListenAddress 10.0.10.21
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AllowGroups ssh-users
Match Group sftp-only
ChrootDirectory /srv/sftp/%u
ForceCommand internal-sftp
AllowTcpForwarding no
Because the first occurrence wins and drop-ins are included at the top, a distribution file like 50-cloud-init.conf with PasswordAuthentication yes can override your later setting — check with sshd -T.
Limits and how it fails
Primary failure point. A valid/effective sshd_config establishes intended daemon policy for a context, but it does not show client trust, credential possession, filesystem permissions or successful downstream workload execution.
Possessing a private key does not guarantee the server accepts the key algorithm, maps the account or authorizes that public key. known_hosts protects server identity and is separate from user authentication. sshd_config syntax success does not show a safe remote reload.
ReferenceConfiguration & state2 sections · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. sshd_config owns server policy syntax and effective Match behavior. sshd owns daemon runtime; Users/Permissions owns local account/file permissions; Firewall owns packet filtering.
Specialized lifecycle
Use the daemon’s configuration test before applying changes and inspect the effective configuration for a representative connection context when Match rules are involved. Keep Include ordering and vendor drop-ins visible. For remote administration, preserve one known-good session and stage authentication/listener changes so rollback remains possible. Understand whether the platform reloads sshd gracefully and whether socket activation or distribution packaging changes service ownership. Do not broaden access merely to make one test succeed.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in SSH → sshd_config. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.openssh.com/manual.html · confidence 94%Authoritative Linux project/vendor documentation reviewed for bounded reference claims: sshd configuration precedence, Match blocks and reload/restart applicability. Documentation-based technical verification only; not lab or production-runtime proof. The schema vendor_doc method is used for authoritative project/vendor documentation; deployment applicability remains separate evidence.
Basis: https://man.openbsd.org/sshd_config · confidence 93%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
sshd_config operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for sshd_config.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | sshd_config defines OpenSSH server policy for listeners, host keys, authentication, account/session behavior, forwarding and subsystems, with Include and Match blocks producing connection-context-specific effective configuration. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin exact client/server + attempt time → resolve destination/TCP path → inspect effective client config → identify OpenSSH versions → verify KEX + host-key trust → trace offered/accepted authentication → inspect effective sshd policy for user/source → verify session/subsystem/forward → verify remote process/filesystem/service → repeat original workload. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | sshd_config/includes → parse validation → global + Match evaluation → daemon loaded policy → new connection → authentication/account checks → channel/subsystem policy → workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | A valid/effective sshd_config establishes intended daemon policy for a context; it does not prove client trust, credential possession, filesystem permissions or successful downstream workload execution. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux SSH evidence can establish this proof path: sshd_config/includes → parse validation → global + Match evaluation → daemon loaded policy → new connection → authentication/account checks → channel/subsystem policy → workload | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured transport, trust, authentication, policy, session, filesystem or workload scope. A valid/effective sshd_config establishes intended daemon policy for a context; it does not prove client trust, credential possession, filesystem permissions or successful downstream workload execution. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven boundary: correlate client and server evidence for the same attempt, inspect effective client/server configuration and identity/trust/authentication state, then test the exact requested session, transfer or forward before changing additional layers. | Continue to the next unresolved boundary while preserving the original test condition. |
sshd_config · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | sshd_config |
|---|---|
| Topic path | SSH → sshd_config |
| Runtime state | sshd_config defines OpenSSH server policy for listeners, host keys, authentication, account/session behavior, forwarding and subsystems, with Include and Match blocks producing connection-context-specific effective configuration. |
| Fast checks | - Run syntax validation before activation and record the exact files/Includes being parsed. - Inspect effective settings for the target user/address context, including Match blocks. - Verify listener, auth methods, forwarding, subsystem and session restrictions relevant to the use case. - Reload/restart only as needed, then establish a new connection and repeat the original operation. |
| Verification chain | sshd_config/includes → parse validation → global + Match evaluation → daemon loaded policy → new connection → authentication/account checks → channel/subsystem policy → workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | A valid/effective sshd_config establishes intended daemon policy for a context; it does not prove client trust, credential possession, filesystem permissions or successful downstream workload execution. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |
sshd_config · specialized operational reference
Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.
| Operational boundary | Topic-specific reference |
|---|---|
| Composition | Main config + Include + Match context |
| Safe apply | Syntax/effective check before reload; keep recovery session |
| Proof | New connection using intended auth path |
| Boundary | Transport → host identity → user auth → session setup |