TMAegis
更多 linux 規則

TMA-ROCKY8-1.7.1

Ensure /etc/motd is configured

中等級 1自動化linux

說明

The contents of the /etc/motd file are displayed to users after login and function as a message of the day for authenticated users. Unix-based systems have typically displayed information about the OS release and patch level upon logging in to the system. This information can be useful to developers who are developing software for a particular OS platform. If mingetty(8) supports the following options, they display operating system information: \m - machine architecture \r - operating system release \s - operating system name \v - operating system version

檢查方式

稽核方法: Shell 指令

shell
alt0() { o=$(bash -c '#!/usr/bin/env bash

{
   l_output="" l_output2=""
   a_files=()
   for l_file in /etc/motd{,.d/*}; do
      if grep -Psqi -- "(\\\v|\\\r|\\\m|\\\s|\b$(grep ^ID= /etc/os-release | cut -d= -f2 | sed -e '"'"'s/"//g'"'"')\b)" "$l_file"; then
         l_output2="$l_output2\n - File: \"$l_file\" includes system information"
      else
         a_files+=("$l_file")
      fi
   done
   if [ "${#a_files[@]}" -gt 0 ]; then
      echo -e "\n-  ** Please review the following files and verify their contents follow local site policy **\n"
      printf '"'"'%s\n'"'"' "${a_files[@]}"
   elif [ -z "$l_output2" ]; then
      echo -e "- ** No MOTD files with any size were found. Please verify this conforms to local site policy ** -"
   fi
   if [ -z "$l_output2" ]; then
      l_output=" - No MOTD files include system information"
      echo -e "\n- Audit Result:\n  ** PASS **\n$l_output\n"
   else
      echo -e "\n- Audit Result:\n  ** FAIL **\n - Reason(s) for audit failure:\n$l_output2\n"
   fi
}' 2>&1); printf '%s\n' "$o" | grep -q '\*\* PASS \*\*' || { echo "step1: script did not report PASS"; return 1; }; }; if alt0; then echo compliant; fi
預期輸出
compliant

修補方式

修補方法: 操作指南或基礎設施修補檔

Edit the file found in /etc/motd.d/* with the appropriate contents according to your site policy, remove any instances of \m , \r , \s , \v or references to the OS platform - OR - - IF - the motd is not used, this file can be removed. Run the following command to remove the motd file: # rm /etc/motd Run the following script and review and/or update all returned files' contents to: • Remove all system information (\v, \r; \m, \s) • Remove any refence to the operating system • Ensure contents follow local site policy #!/usr/bin/env bash { a_files=() for l_file in /etc/motd{,.d/*}; do if grep -Psqi -- "(\\\v|\\\r|\\\m|\\\s|\b$(grep ^ID= /etc/os-release | cut -d= -f2 | sed -e 's/"//g')\b)" "$l_f…

屬性

作業系統
rocky-8
標籤
cis-convertedlinux
參考資料
CIS Rocky Linux 8 Benchmark v3.0.0 - 1.7.1

檢查此主機

請在您有權稽核的機器上執行此指令。掃描為唯讀操作。

shell
tmaegis scan --target linux