sshd_config — OpenSSH server authentication
OpenSSH server reads /etc/ssh/sshd_config with supported Include and Match scopes. Most global values use the first encountered setting; Match clauses can override eligible global settings for matching connections. Upstream and distro defaults differ; inspect effective settings rather than assuming. PermitRootLogin controls root login, PasswordAuthentication controls password method, PubkeyAuthentication controls public-key method. Disabling password authentication alone does not necessarily disable keyboard-interactive authentication. Confirm keys and recovery access before changing authentication. Restrict installed config to authorized admin edits. sshd -t validates syntax and key sanity; sshd -T -C evaluates effective settings for a connection context. A private file without host keys may fail validation; the example generates a temporary host key, never starts sshd. Only approved reload after validating full configuration; preserve existing admin session and test new login. Restore previous config and reload via recovery console if needed.
Formal Syntax & Structure
PermitRootLogin noPasswordAuthentication noPubkeyAuthentication yesParameters & Attributes
| Name | Type | Description |
|---|---|---|
| PermitRootLogin | directive | Root login policy |
| PasswordAuthentication | directive | Password method policy |
| PubkeyAuthentication | directive | Public key method policy |
| KbdInteractiveAuthentication | directive | Keyboard-interactive method policy |
| Match | directive | Conditional scope |
Return Value
Effective settings or syntax-check result, not proof of successful login.
Working Example
set -eud=$(mktemp -d)trap 'rm -rf -- "$d"' EXITssh-keygen -q -t ed25519 -N '' -f "$d/host_key"cat > "$d/sshd_config" <<EOFHostKey $d/host_keyPermitRootLogin noPasswordAuthentication noKbdInteractiveAuthentication noPubkeyAuthentication yesEOFsshd -t -f "$d/sshd_config"printf 'private sshd syntax accepted\n'