Remediations involving sshd_config

Truhn, Chad M CTR NSWCDD, CXA30 chad.m.truhn.ctr at navy.mil
Tue Oct 8 14:14:55 UTC 2013


>	# Attempt to adjust value, should string be present
>	grep -q ^PermitEmptyPasswords /etc/ssh/sshd_config && \
>	  sed -i "s/PermitEmptyPasswords.*/PermitEmptyPasswords no/g" /etc/ssh/sshd_config
>	if ! [ $? -eq 0 ]; then
>	        # string not present, check for Match stanza
>	        grep -q ^Match /etc/ssh/sshd_config && \
>	                sed '0,/.*Match.*/s/.*Match*./PermitEmptyPasswords no\n&/' /etc/ssh/sshd_config
>	        if ! [ $? -eq 0 ]; then
>	                # Match stanza not present, add to bottom of /etc/ssh/sshd_config
>	                echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config
>	        fi
>	fi


- sed '0,/.*Match.*/s/.*Match*./PermitEmptyPasswords no\n&/' /etc/ssh/sshd_config
+ sed -i '0,/.*Match.*/s/.*Match*./PermitEmptyPasswords no\n&/' /etc/ssh/sshd_config

Sorry I don't have a great cleanup of that, but gotta add the '-i'  :)


More information about the scap-security-guide mailing list