Audit Activities

Last modified on March 24, 2023

This document explains how to set up a regular export of admin activity in an organization. By leveraging the sdm audit functionality, you retrieve a list of activities every five minutes and write them to a JSON file. A separate tool can then import these files into a log aggregator or SIEM.

Initial Setup

We recommend creating a new Linux system user with restricted permissions to run the audit. In this example, we use sdm. Download and install the Linux SDM client.

Create an Admin Token

To create an admin token, sign into the StrongDM Admin UI and go to Access > API & Admin Tokens. From there you can create an admin token with the specific rights you require—in this case, only the Audit > Activities permission.

After you click Create, a dialog displays the admin token. Copy the token, and save it for later use in /etc/sdm-admin.token in the format SDM_ADMIN_TOKEN=<YOUR_TOKEN>.

This file must be owned by your user.

chown sdm:sdm /etc/sdm-admin.token

For more details on creating admin tokens, see Create Admin Tokens.

Example Activity Export Script

Here is an example activity export script that in the next step we set up to run periodically. You may note that this script is really just one command: we set it up as a script for clarity but if you prefer you can insert just the sdm audit... command directly into crontab.

export SDM_ADMIN_TOKEN=<insert admin token here>
START=$(date -d "5 minutes ago" '+%Y-%m-%dT%H:%M:00') # start of audit slice, defaulting to 5 minutes ago
FN=$(date -d "yesterday 00:00" '+%Y%m%d%H%M') # timestamp string to append to output filename
END=$(date '+%Y-%m-%dT%H:%M:00') # end of audit slice, defaulting to now, at the top of the minute
TARGET=/var/log/sdm # location where JSON files are written

/opt/strongdm/bin/sdm audit activities --from "$START" --to "$END" -j > "$TARGET/activities.$FN.json"

Add Crontab Entry

Although most Linux systems have locations to place scripts that run daily, weekly, and so on, the script is configured by default to run every five minutes. As such, our best bet is to place it directly into the crontab file for a user or for the system.

Add this line to the crontab of your choice, modifying the interval to match what you set in the script:

*/5 * * * * /path/to/