configuration

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

linux syntaxlinux
PermitRootLogin noPasswordAuthentication noPubkeyAuthentication yes

Parameters & Attributes

NameTypeDescription
PermitRootLogindirectiveRoot login policy
PasswordAuthenticationdirectivePassword method policy
PubkeyAuthenticationdirectivePublic key method policy
KbdInteractiveAuthenticationdirectiveKeyboard-interactive method policy
MatchdirectiveConditional scope

Return Value

configuration or inspection

Effective settings or syntax-check result, not proof of successful login.

Working Example

Example Snippetlinux
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'
Linux Reference