Ensuring remote root login is disabled

In the previous chapter, we devised the following shell script to test for the condition described in CIS Benchmark recommendation 5.2.8 (RHEL 7, benchmark version 2.2.0), and then implemented it if the condition was not met. It is included here so that it can be contrasted against the Ansible solution we are about to create:

#!/bin/bash## This file implements CIS Red Hat Enterprise Linux 7 Benchmark # Recommendation 5.2.8 from version 2.2.0echo -n "Ensure root logins are disabled on SSH... "OUTPUT=$(grep -e "^PermitRootLogin no" /etc/ssh/sshd_config)if [ "x$OUTPUT" == "x" ]; then  echo FAILED!  OPTPRESENT=$(grep -e "^PermitRootLogin.*" /etc/ssh/sshd_config)  if [ "x$OPTPRESENT" == "x" ]; then echo "Configuration ...

Get Hands-On Enterprise Automation on Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.