Skip to content

Commit 853c492

Browse files
committed
Verify that the directives are actually disabled after restarting sshd
Ticket: ENT-13766 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 636eb4d commit 853c492

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

ci/cfengine-build-host-setup.cf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,25 @@ jenkins_builds ALL=NOPASSWD: /usr/bin/podman
375375
!have_sys_user.(suse|sles|opensuse)::
376376
"useradd -u 3 sys" contain => in_shell;
377377

378+
linux::
379+
"sshd -T 2>/dev/null | grep -qiE '^PermitRootLogin no'"
380+
depends_on => { "sshd_restarted" },
381+
contain => in_shell,
382+
comment => "Verify PermitRootLogin is disabled";
383+
"sshd -T 2>/dev/null | grep -qiE '^PasswordAuthentication no'"
384+
depends_on => { "sshd_restarted" },
385+
contain => in_shell,
386+
comment => "Verify PasswordAuthentication is disabled";
387+
"sshd -T 2>/dev/null | grep -qiE '^(KbdInteractive|ChallengeResponse)Authentication no'"
388+
depends_on => { "sshd_restarted" },
389+
contain => in_shell,
390+
comment => "Verify KbdInteractiveAuthentication (OpenSSH 8.7+) or ChallengeResponseAuthentication (older) is disabled";
391+
378392
services:
379393
sshd_hardened::
380394
"sshd"
381395
service_policy => "restart",
396+
handle => "sshd_restarted",
382397
comment => "Restart sshd to apply hardened configuration";
383398
any::
384399
"fail2ban"

0 commit comments

Comments
 (0)