Remediations involving sshd_config
Shawn Wells
shawn at redhat.com
Fri Oct 4 03:17:26 UTC 2013
On 10/3/13 10:08 AM, Rui Pedro Bernardino wrote:
> Hi all,
>
> The remediation won't work if it appends the new option to the end of file AND there are 'Match' rules (from sshd_config's: "If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file, until either another Match line or the end of the file.").
>
> Although commented, 'Match' rules are in the default sshd_config.
>
> For example, for "sshd_enable_warning_banner.sh", my suggestion would be:
> ==================================
> grep -q ^Banner /etc/ssh/sshd_config && \
> sed -i "s/Banner.*/Banner \/etc\/issue/g" /etc/ssh/sshd_config
> if ! [ $? -eq 0 ]; then
> ed -s /etc/ssh/sshd_config <<'EOF'
> /Match/
> ?^[A-Z]?
> +
> i
> Banner /etc/issue
> .
> w
> q
> EOF
> fi
> ==================================
> This will add a new line, after the last keyword before the first 'Match' block (including comments). I'm ashamed to say I couldn't do it with 'sed':(
>
> Does it sound reasonable?
This situation *should* be taken care of. Are you experiencing something
different than the situation below?
1) Testing file with no Banner value set:
> [shawn at SSG-RHEL6 checks]$ sudo grep Banner /etc/ssh/sshd_config
> #Banner none
>
> [shawn at SSG-RHEL6 checks]$ sudo ./testcheck.py
> sshd_enable_warning_banner.xml
> Evaluating with OVAL tempfile : /tmp/sshd_enable_warning_bannerzkgnCU.xml
> Writing results to : /tmp/sshd_enable_warning_bannerzkgnCU.xml-results
> Definition oval:scap-security-guide.testing:def:129: false
> Definition oval:scap-security-guide.testing:def:127: false
> Definition oval:scap-security-guide.testing:def:126: false
> Evaluation done.
>
> [shawn at SSG-RHEL6 checks]$ sudo bash
> ../fixes/bash/sshd_enable_warning_banner.sh
> [shawn at SSG-RHEL6 checks]$ sudo grep Banner /etc/ssh/sshd_config
> #Banner none
> Banner /etc/issue
>
> [shawn at SSG-RHEL6 checks]$ sudo ./testcheck.py
> sshd_enable_warning_banner.xml
> Evaluating with OVAL tempfile : /tmp/sshd_enable_warning_banner43kR1V.xml
> Writing results to : /tmp/sshd_enable_warning_banner43kR1V.xml-results
> Definition oval:scap-security-guide.testing:def:129: false
> Definition oval:scap-security-guide.testing:def:127: false
> Definition oval:scap-security-guide.testing:def:126: true
> Evaluation done.
2) Testing if incorrect Banner value set
> [shawn at SSG-RHEL6 checks]$ sudo grep Banner /etc/ssh/sshd_config
> #Banner none
> Banner /totally/wrong/path
>
> [shawn at SSG-RHEL6 checks]$ sudo ./testcheck.py
> sshd_enable_warning_banner.xml
> Evaluating with OVAL tempfile : /tmp/sshd_enable_warning_banneryFifQw.xml
> Writing results to : /tmp/sshd_enable_warning_banneryFifQw.xml-results
> Definition oval:scap-security-guide.testing:def:129: false
> Definition oval:scap-security-guide.testing:def:127: false
> Definition oval:scap-security-guide.testing:def:126: false
> Evaluation done.
>
> [shawn at SSG-RHEL6 checks]$ sudo bash
> ../fixes/bash/sshd_enable_warning_banner.sh
> [shawn at SSG-RHEL6 checks]$ sudo grep Banner /etc/ssh/sshd_config
> #Banner /etc/issue
> Banner /etc/issue
>
> [shawn at SSG-RHEL6 checks]$ sudo ./testcheck.py
> sshd_enable_warning_banner.xml
> Evaluating with OVAL tempfile : /tmp/sshd_enable_warning_bannervMyGwb.xml
> Writing results to : /tmp/sshd_enable_warning_bannervMyGwb.xml-results
> Definition oval:scap-security-guide.testing:def:129: false
> Definition oval:scap-security-guide.testing:def:127: false
> Definition oval:scap-security-guide.testing:def:126: true
> Evaluation done.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/scap-security-guide/attachments/20131003/c78d79d1/attachment-0001.html>
More information about the scap-security-guide
mailing list