Interview Prep/DevSecOps/DAST, runtime detection and compliance scans

The InSpec CIS profile fails `PasswordAuthentication should be no` on the golden AMI, although the Ansible hardening role sets it in `/etc/ssh/sshd_config`

IntermediateTroubleshootingDAST, runtime detection and compliance scans
Answer

Likely causes → On recent Ubuntu, Debian and RHEL releases, sshd_config starts with Include /etc/ssh/sshd_config.d/*.conf, and sshd uses the first value it reads. A drop-in like 50-cloud-init.conf setting PasswordAuthentication yes wins over your line further down.

Diagnose →

sudo sshd -T | grep -i passwordauthentication     # effective config
grep -ri passwordauthentication /etc/ssh/sshd_config.d/

Fix → Write your hardening as a drop-in that sorts first (for example /etc/ssh/sshd_config.d/00-hardening.conf), or remove the conflicting drop-in, then run sshd -t && systemctl reload ssh.

Prevent → Test with the effective config (sshd -T) in the image pipeline. InSpec's sshd_active_config resource checks the running state.

All DevSecOps questions Roadmap: Policy as code

More on DAST, runtime detection and compliance scans