---
title: Ensure MOTD Files Do Not Disclose System Information
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Ensure MOTD Files Do Not Disclose
  System Information
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Ensure MOTD Files Do Not Disclose System Information
 
## Description{% #description %}

The message of the day shown after login comes from the files `/etc/motd`, `/run/motd` and `/usr/lib/motd`, from the files in `/etc/motd.d`, `/run/motd.d` and `/usr/lib/motd.d`, and from the scripts in `/etc/update-motd.d`. None of these files may contain the escape sequences `\m`, `\r`, `\s` or `\v`, or the operating system identifier, the `ID` of `/etc/os-release`, as a word in any letter case. Edit each file that does to follow the local site policy, or remove the file if it is not used, for example:

```
$ sudo rm /etc/update-motd.d/10-help-text
```

## Rationale{% #rationale %}

Warning messages inform users who are attempting to login to the system of their legal status regarding the system and must include the name of the organization that owns the system and any monitoring policies that are in place. Displaying OS and patch level information in login banners also has the side effect of providing detailed system information to attackers attempting to target specific exploits of a system. Authorized users can easily get this information by running the `uname -a` command once they have logged in.

## Remediation{% #remediation %}

### Shell script{% #shell-script %}

The following script can be run on the host to remediate the issue.

```bash
#!/bin/bash

# Remediation is applicable only in certain platforms
if dpkg-query --show --showformat='${db:Status-Status}' 'linux-base' 2>/dev/null | grep -q '^installed$'; then

os_id=$(grep '^ID=' /etc/os-release 2>/dev/null | cut -d= -f2 | sed -e 's/"//g')
pattern='(\\v|\\r|\\m|\\s'
if [[ -n "$os_id" ]]; then
    pattern="$pattern|\\b$os_id\\b"
fi
pattern="$pattern)"

for motd_file in /etc/motd /run/motd /usr/lib/motd /etc/motd.d/* /run/motd.d/* /usr/lib/motd.d/* /etc/update-motd.d/*; do
    if [[ -f "$motd_file" ]] && grep -Psqi -- "$pattern" "$motd_file"; then
        rm -f "$motd_file"
    fi
done

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi
```
