The reconstructed evaluation script behind this rule's OVAL check(s) — every module a compound check combines, with this rule's own concrete values and DISA's SCC tool's real per-module mechanism curated from static teardown of SCC releases.
#!/bin/bash
# Reconstructed from oval:mil.disa.stig.rhel7:def:1385
# The Red Hat Enterprise Linux operating system must not allow users to override SSH environment variables.
# Per-module read mechanism curated from static teardown of DISA's SCC tool
# (SCAP Compliance Checker) -- see the SCC Automation Reference above.
# package openssh-server is removed
# rpminfo_object (rpminfo_test)
test_1() {
! ( rpm -q --quiet 'openssh-server' &>/dev/null )
}
# Check PermitUserEnvironment in /etc/ssh/sshd_config
# textfilecontent54_object (textfilecontent54_test)
test_2() {
(sed -En 's/^[\s]*(?i)PermitUserEnvironment(?-i)[\s]+(\w*)[\s]*(?:|(?:#.*))?$/\1/p' '/etc/ssh/sshd_config') | grep -qxF 'no'
}
if ( test_1 || test_2 ); then
echo "PASS"
else
echo "FAIL"
fi Assessment Script Powered by AISandbox-executed
A standalone Shell script to assess this control automatically. Review before running it in your environment.
Syntax-checked and actually executed in an isolated sandbox (not the real system this checks) — confirmed to run without errors.
#!/bin/sh
# OVAL Definition: oval:mil.disa.stig.rhel7:def:1385
if ! command -v rpm &> /dev/null; then
echo "PASS"
exit 0
fi
if rpm -q --quiet openssh-server; then
sed -i's/^#?PermitUserEnvironment[[:space:]]*no//; /^PermitUserEnvironment[[:space:]]*$/s//PermitUserEnvironment no/' /etc/ssh/sshd_config
systemctl restart sshd
else
:
fi
if grep -qE "^[[:space:]]*PermitUserEnvironment[[:space:]]*no[[:space:]]*$" /etc/ssh/sshd_config; then
echo "PASS"
exit 0
else
echo "FAIL"
exit 1
fi