feat(ssh-server): read how sshd lets people log in #99

Merged
christianmanivong merged 1 commits from feat/ssh-server-auth into main 2026-11-07 18:44:44 +00:00
Owner

What

SshServerAuthMixin.get_ssh_server_auth() (new module ssh_server_auth.py): how an OpenSSH server lets people log in.

  • From sshd -T as root, the same fixed command OpenSshServerMixin plans its hardening on (SSHD_EFFECTIVE_COMMAND, now shared by both): password_authentication, kbd_interactive_authentication (before OpenSSH 8.7 also ChallengeResponseAuthentication), pubkey_authentication, hostbased_authentication, gssapi_authentication, authentication_methods as lists of methods (empty for any), permit_root_login, use_pam (None where sshd has no PAM, OpenBSD).
  • With UsePAM yes, pam_auth_stack: sshd's PAM auth stack, each module with its control and arguments, read as the login user from one fixed listing of /etc/pam.d (tail -n +1 -- /etc/pam.d/*) and followed through @include, include and substack (a loop or a missing file is skipped, an include naming a path is ignored). None when PAM is off or nothing for sshd could be read.
  • OpenSshServerMixin now inherits SshServerAuthMixin, so napalm-linux and its descendants (OMV, QNAP, Proxmox VE/PBS) get the getter with this release and no driver change.

Facts, not policy: whether a module is a second factor, or whether nullok lets a user through, is the consumer's call. Match blocks are not read (sshd -T without -C). A failed sshd -T raises RuntimeError.

Why

NetOrk/netork#662: NIS2 Art. 21(2)(j) MFA on the managed systems, judged from the SSH server's effective settings (decided there on 2026-11-07).

Tests

Fixtures only: the sshd -T and PAM texts are written after what OpenSSH 9.2p1 on Debian 12, Red Hat's password-auth layout and FreeBSD print, not recorded from a device. tests/test_ssh_server_auth.py: the parsers (every keyword, old ChallengeResponse keyword, no usepam, missing GSSAPI, not-sshd output, bracketed controls, paths, optional lines, invalid includes), the include walk (substack, loop, missing file), and the getter against a fake host (sshd -T once as root, PAM once without root, partial tail output, no PAM, failed read). 100 % coverage of the new module; ruff, mypy strict, napalm-standard check and ratchet green; the full suite passes.

Not tagged or released: the release is the coordinator's.

Refs NetOrk/netork#662

## What `SshServerAuthMixin.get_ssh_server_auth()` (new module `ssh_server_auth.py`): how an OpenSSH server lets people log in. - From `sshd -T` as root, the same fixed command `OpenSshServerMixin` plans its hardening on (`SSHD_EFFECTIVE_COMMAND`, now shared by both): `password_authentication`, `kbd_interactive_authentication` (before OpenSSH 8.7 also `ChallengeResponseAuthentication`), `pubkey_authentication`, `hostbased_authentication`, `gssapi_authentication`, `authentication_methods` as lists of methods (empty for `any`), `permit_root_login`, `use_pam` (None where sshd has no PAM, OpenBSD). - With `UsePAM yes`, `pam_auth_stack`: sshd's PAM `auth` stack, each module with its control and arguments, read as the login user from one fixed listing of `/etc/pam.d` (`tail -n +1 -- /etc/pam.d/*`) and followed through `@include`, `include` and `substack` (a loop or a missing file is skipped, an include naming a path is ignored). None when PAM is off or nothing for sshd could be read. - `OpenSshServerMixin` now inherits `SshServerAuthMixin`, so napalm-linux and its descendants (OMV, QNAP, Proxmox VE/PBS) get the getter with this release and no driver change. Facts, not policy: whether a module is a second factor, or whether `nullok` lets a user through, is the consumer's call. `Match` blocks are not read (`sshd -T` without `-C`). A failed `sshd -T` raises `RuntimeError`. ## Why NetOrk/netork#662: NIS2 Art. 21(2)(j) MFA on the managed systems, judged from the SSH server's effective settings (decided there on 2026-11-07). ## Tests Fixtures only: the `sshd -T` and PAM texts are written after what OpenSSH 9.2p1 on Debian 12, Red Hat's `password-auth` layout and FreeBSD print, not recorded from a device. `tests/test_ssh_server_auth.py`: the parsers (every keyword, old ChallengeResponse keyword, no `usepam`, missing GSSAPI, not-sshd output, bracketed controls, paths, optional lines, invalid includes), the include walk (substack, loop, missing file), and the getter against a fake host (sshd -T once as root, PAM once without root, partial `tail` output, no PAM, failed read). 100 % coverage of the new module; ruff, mypy strict, `napalm-standard check` and `ratchet` green; the full suite passes. Not tagged or released: the release is the coordinator's. Refs NetOrk/netork#662
christianmanivong added 1 commit 2026-11-07 14:33:43 +00:00
feat(ssh-server): read how sshd lets people log in
driver / lint (pull_request) Successful in 15s
driver / standard (pull_request) Successful in 17s
driver / types (pull_request) Successful in 1m10s
driver / test (3.13) (pull_request) Successful in 1m25s
driver / test (3.12) (pull_request) Successful in 1m32s
driver / lowest (pull_request) Successful in 44s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m5s
CI / driver (pull_request) Successful in 2m48s
driver / publish (pull_request) Skipped
1d71ff8f91
SshServerAuthMixin.get_ssh_server_auth() reads the authentication settings
from sshd -T as root (password, keyboard-interactive, public key, host-based,
GSSAPI, AuthenticationMethods, PermitRootLogin, UsePAM) and, with PAM on, the
modules of sshd's PAM auth stack from /etc/pam.d with its includes followed.
It reports the facts; whether a module is a second factor is the consumer's
call. OpenSshServerMixin carries it and both read sshd -T by the same fixed
command, so every driver that can harden sshd can say this too.

Refs NetOrk/netork#662
christianmanivong merged commit b7e31205d5 into main 2026-11-07 18:44:44 +00:00
christianmanivong deleted branch feat/ssh-server-auth 2026-11-07 18:44:44 +00:00
Sign in to join this conversation.