docs/documentation/platform/pam/product-reference/account-policies.mdx
Account Policies let you define behavioral rules that are enforced on PAM accounts during sessions. Use them to block dangerous commands, mask sensitive data in session logs, or both.
An account policy is a named, project-scoped configuration that contains one or more rules. Each rule targets a specific behavior:
| Rule Type | Description | Supported Resources |
|---|---|---|
| Command Blocking | Prevents execution of commands matching specified regex patterns. | SSH |
| Session Log Masking | Redacts data matching specified regex patterns from session logs. | All resource types |
| Require Access Reason | Requires the user to provide a reason before a session can start. The reason is stored for audit. | All resource types |
A policy can be active or inactive. Only active policies are enforced during sessions.
Navigate to your PAM project sidebar and click Account Policies, then click Create Policy.
<Steps> <Step title="Name and Description"> Provide a **name** for the policy (must be unique within the project) and an optional **description**.
- **Command Blocking**: Add one or more regex patterns. Commands matching any of these patterns will be blocked during SSH sessions.
- **Session Log Masking**: Add one or more regex patterns. Any data matching these patterns will be redacted in session logs.
- **Require Access Reason**: Forces the user to provide a non-empty reason before they can start a session. When the rule is active, the CLI prompts for a reason (or accepts the `--reason` flag) and the browser shows a Reason Required screen before the session is created.
For each rule, click the **+** button to add additional patterns.

Here's an example of command blocking in action during a live SSH session:

And session logs with masked sensitive data:

When creating or editing an Account, select a policy from the Account Policy dropdown. Each account can have at most one policy assigned. Multiple accounts can share the same policy.
If a policy is deleted, any accounts that were using it will have their policy reference removed automatically.
You can toggle a policy between active and inactive from the account policies list page using the switch in the Active column. Inactive policies are not enforced during sessions.
Click the three-dot menu on any policy row and select Edit to open the policy sheet. You can modify the name, description, and rules of the policy.
Click the three-dot menu on any policy row and select Delete. Deleting a policy removes it from all accounts that reference it.
Patterns use standard regular expression syntax. Some examples:
| Pattern | Effect |
|---|---|
rm\s+-rf | Blocks rm -rf commands (command blocking) |
sudo\s+su | Blocks sudo su commands (command blocking) |
password=.* | Masks password values in logs (session log masking) |
api[_-]?key=.* | Masks API key values in logs (session log masking) |
Because matches are evaluated with regular expressions, patterns need to cover the different ways a command might be typed, and exhaustive coverage of every variation is difficult to guarantee in practice. It is highly recommended to pair command blocking with target-side controls like restricted shells or sudoers rules where those are available.
</Note>