---
title: Configure Access to pam_motd Message Files
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Configure Access to pam_motd Message
  Files
---

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

# Configure Access to pam_motd Message Files
 
## Description{% #description %}

The files that the lines of `/etc/pam.d` name with `motd=PATH`, commented lines included, must be owned by root, group-owned by root, and have mode 0644 or more restrictive. A `motd=` value can name several files, separated by colons.

## Rationale{% #rationale %}

Restrictive ownership and permissions prevent unauthorized modification of text displayed to users at login.

## 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}' 'libpam-runtime' 2>/dev/null | grep -q '^installed$'; then

# The value of motd= is a colon-separated list of files (pam_motd(8)).
while IFS= read -r motd_path; do
    motd_path=${motd_path#\"}; motd_path=${motd_path%\"}
    motd_path=${motd_path#\'}; motd_path=${motd_path%\'}
    [[ -e "$motd_path" ]] || continue
    chown root:root "$motd_path"
    chmod u-x,go-wx "$motd_path"
done < <(grep -hPo '\bmotd=\K("[^"]+"|'"'"'[^'"'"']+'"'"'|\S+)' /etc/pam.d/* 2>/dev/null | tr ':' '\n' | sort -u)

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