Skip to content

SOC 2 evidence collection for a Linux-VM stack — what to capture, where it lives, how to make it auditor-ready

A concrete inventory of the infrastructure evidence a SOC 2 Type II auditor will sample on a Linux-VM stack, what command produces each artifact, and how to keep the pile fresh between windows.

You walked out of the SOC 2 gap-analysis meeting with a fourteen-line spreadsheet, a target observation window that starts in three weeks, and the dawning realization that nobody on the team has ever exported an evidence pack. Your auditor talks about “evidence” the way your platform team talks about logs — a thing that should already exist, in a known location, with timestamps. The problem is that on a Linux-VM stack the artifacts live in nine different places: the cloud console, the IdP, the secrets manager, the deploy log, the OS itself, the database, the monitoring stack, the ticket system, and the WAF. None of them produce a clean “control X operated on date Y” file on their own. You have to assemble it.

This runbook is the assembly manual, not legal or audit advice. Engage a licensed CPA firm for attestation work; Stack Harbor operates infrastructure controls, we do not perform audits.

What’s happening

A SOC 2 Type II auditor evaluates whether a control operated consistently over the observation window. They do not read your policies for fun — they read them to find a control statement, then ask for a sample of evidence that the control fired on specific dates. The sample is typically five to fifteen artifacts per control across the window, drawn at random. Evidence is concrete: screenshots with URL and timestamp visible, CSV exports with the request and response captured, signed-and-dated runbook executions, log lines with millisecond precision. “We do this regularly” is not evidence. A wall of Confluence pages is not evidence. An exported file from a system of record, on a date the auditor names, is evidence.

The Linux-VM stack makes this harder than a SaaS-only stack because the artifacts are scattered: IAM lives in your IdP, OS-level access lives in /var/log/auth.log and the bastion, deploy approvals live in the CI logs, encryption posture lives in cryptsetup and the cloud KMS, backups live in your snapshot tool, monitoring lives in Prometheus or Datadog, vulnerability scans live in the scanner, change records live in the ticket system, and incidents live in the postmortem repository. The mistake every first-time auditee makes is trying to write a “evidence collection script” that pulls all of it on demand the week before the auditor’s sample request lands. By the time the request lands it is too late — log retention has aged out, the snapshot you would have referenced is gone, the IdP only kept 30 days of events on the standard tier. Evidence has to accumulate continuously into a durable store, indexed by control reference and date, so the sample request becomes a directory listing.

How to verify

The cheapest way to know whether your evidence pile is in shape is to pick three random dates from the observation window and try to assemble a single control’s evidence packet for each date. If you can do it in under fifteen minutes without asking anyone, the control is operating. If you cannot, you have a gap before the auditor finds it.

For access controls, the IdP should produce a CSV of active privileged users for any date in the window:

# Example: dump current admin-group membership from your IdP
# (replace with your IdP's CLI — Okta, Entra, Google, Authentik, Keycloak)
okta users list --group admin --format csv > evidence/access/admins-$(date +%F).csv

For the OS layer, sudo activity on each host is captured in /var/log/auth.log (Debian/Ubuntu) or /var/log/secure (RHEL/AlmaLinux), shipped to a central log store, and retained beyond the observation window plus a buffer:

# Sample a privileged action from the host
grep 'COMMAND=' /var/log/auth.log | tail -20
# Confirm shipping to the central store
journalctl -u rsyslog --since "1 hour ago" | grep -i 'forwarded'

For deploy approvals, the CI system should expose an immutable record of who approved each production deploy:

# Example: list the last 30 production deploys with approver
gh run list --workflow=deploy-prod.yml --limit 30 \
  --json databaseId,headSha,createdAt,event,conclusion,actor \
  > evidence/change/deploys-$(date +%F).json

For encryption posture, on each VM:

# Confirm root or data volume is encrypted at rest
sudo cryptsetup status data
# Or, if the encryption is at the cloud-volume layer:
aws ec2 describe-volumes --volume-ids vol-xxx --query 'Volumes[].Encrypted'
# TLS posture on a public endpoint
curl -Iv https://app.example.com 2>&1 | grep -E '(TLSv|cipher)'

For backups, the snapshot tool should expose a list of completed backups with timestamps:

# Example with restic
restic snapshots --json | jq '.[] | {id,time,paths,size}'
# Plus the most recent restore-drill log
cat evidence/backups/restore-drill-$(date +%F | cut -d- -f1-2)*.log

For monitoring, the alert system should expose an audit trail of fired alerts and acknowledgements:

# Example: export PagerDuty incidents over the window
pd incident list --since "2026-02-01" --until "2026-05-01" --format json \
  > evidence/monitor/incidents-2026q1.json

Any of these that errors out, or that returns nothing for a known event in the window, is a control gap masquerading as a tooling gap.

The fix

Stand up a continuous evidence-collection job that runs on a cron, pushes artifacts into an append-only object store, names them by control reference and date, and produces a manifest the auditor can read directly. The script below is the version we deploy on Linux-VM stacks running under Managed Cloud Ops — AlmaLinux 9 host, systemd timer, S3-compatible object store, GPG signing for the manifest. Edit the variables at the top, save as /usr/local/sbin/soc2-evidence-collect.sh, and let the timer accumulate the pile.

#!/usr/bin/env bash
set -euo pipefail

### SOC 2 evidence-collection cron — Linux-VM stack
### Runs daily; pushes a dated bundle to object storage with manifest + signature
### Naming convention: <CONTROL-REF>/<YYYY-MM-DD>-<artifact>.<ext>

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT PER ENVIRONMENT ===
ENV_NAME="prod-ca-central-1"
BUCKET="s3://acme-soc2-evidence"
GPG_KEY_ID="0xDEADBEEFCAFE1234"          # signing key for the daily manifest
RETENTION_DAYS=400                        # observation window + buffer
IDP_TOOL="okta"                           # okta | entra | gcloud | authentik
LOG_SHIPPER_UNIT="rsyslog"                # systemd unit shipping logs to central store
SCAN_TOOL="trivy"                         # trivy | grype
# ============================

DATE=$(date -u +%F)
TS=$(date -u +%FT%TZ)
WORK=/var/lib/soc2-evidence/$DATE
mkdir -p "$WORK"/{access,change,encryption,backups,monitor,vulns,os}

echo "==> [$TS] SOC 2 evidence collection start on ${ENV_NAME}"

# --- CC6.1 / CC6.2: logical access ---
echo "==> CC6.1: privileged-group export"
case "$IDP_TOOL" in
  okta)     okta users list --group admin --format csv > "$WORK/access/admins.csv" || true ;;
  entra)    az ad group member list --group "Cloud-Admins" -o table > "$WORK/access/admins.csv" || true ;;
  gcloud)   gcloud projects get-iam-policy "$ENV_NAME" --format=json > "$WORK/access/iam-policy.json" || true ;;
  authentik) ak users list --group admin -o json > "$WORK/access/admins.json" || true ;;
esac

# Sudo activity per host, last 24h
journalctl --since "24 hours ago" _COMM=sudo > "$WORK/access/sudo-$(hostname).log" || true

# SSH session log via auditd if installed
if systemctl is-active --quiet auditd; then
  ausearch -m USER_LOGIN -ts today > "$WORK/access/ssh-logins.log" 2>/dev/null || true
fi

# --- CC7.2: change management ---
echo "==> CC7.2: deploy approvals (last 24h)"
if command -v gh >/dev/null 2>&1; then
  gh run list --workflow=deploy-prod.yml --limit 50 \
    --json databaseId,headSha,createdAt,event,conclusion,actor,headBranch \
    --jq "[.[] | select(.createdAt > \"$(date -u -d '24 hours ago' +%FT%TZ 2>/dev/null || date -u -v-1d +%FT%TZ)\")]" \
    > "$WORK/change/deploys.json" || true
fi

# Disabled force-push protection check
if command -v gh >/dev/null 2>&1; then
  gh api repos/acme/app/branches/main/protection > "$WORK/change/branch-protection.json" 2>/dev/null || true
fi

# --- CC6.7 / CC6.8: encryption at rest + in transit ---
echo "==> CC6.7: encryption posture"
lsblk -o NAME,FSTYPE,TYPE,MOUNTPOINT > "$WORK/encryption/lsblk.txt" || true
if command -v cryptsetup >/dev/null 2>&1; then
  for d in $(ls /dev/mapper 2>/dev/null | grep -v control); do
    cryptsetup status "/dev/mapper/$d" >> "$WORK/encryption/luks-status.txt" 2>&1 || true
  done
fi
# TLS posture on configured endpoints
for host in app.example.com api.example.com admin.example.com; do
  echo "=== $host ===" >> "$WORK/encryption/tls.txt"
  ( echo | openssl s_client -connect "${host}:443" -servername "$host" 2>/dev/null \
    | openssl x509 -noout -dates -subject -issuer ) >> "$WORK/encryption/tls.txt" 2>&1 || true
done

# --- CC8.1: backups + restore-drill log presence ---
echo "==> CC8.1: backup state"
if command -v restic >/dev/null 2>&1; then
  restic snapshots --json > "$WORK/backups/restic-snapshots.json" 2>/dev/null || true
fi
# Surface the most recent restore-drill record if it exists
find /var/log/soc2/restore-drills -type f -mtime -100 -name '*.log' \
  -exec cp -p {} "$WORK/backups/" \; 2>/dev/null || true

# --- CC7.3: monitoring + alerts ---
echo "==> CC7.3: monitoring health"
if command -v promtool >/dev/null 2>&1; then
  promtool query instant http://localhost:9090 'up' > "$WORK/monitor/prom-up.txt" 2>&1 || true
  promtool query instant http://localhost:9090 'ALERTS' > "$WORK/monitor/prom-alerts.txt" 2>&1 || true
fi

# --- CC7.1: vulnerability scan ---
echo "==> CC7.1: vulnerability scan"
case "$SCAN_TOOL" in
  trivy)
    trivy fs / --skip-dirs /proc,/sys,/var/lib/soc2-evidence \
      --severity HIGH,CRITICAL --format json --quiet \
      > "$WORK/vulns/trivy.json" 2>/dev/null || true
    ;;
  grype)
    grype dir:/ --output json --quiet > "$WORK/vulns/grype.json" 2>/dev/null || true
    ;;
esac

# --- A1.2 / availability ---
echo "==> A1.2: system uptime + service inventory"
uptime > "$WORK/os/uptime.txt"
systemctl list-units --type=service --state=running --no-pager --plain \
  > "$WORK/os/services.txt"
ss -lntp > "$WORK/os/listeners.txt" 2>/dev/null || true
last -20 > "$WORK/os/logins.txt" || true

# --- Manifest + signature ---
echo "==> Building manifest"
(
  cd "$WORK"
  find . -type f -not -name 'MANIFEST*' -print0 \
    | xargs -0 sha256sum > MANIFEST.sha256
  echo "env=$ENV_NAME" > MANIFEST.meta
  echo "collected_at=$TS" >> MANIFEST.meta
  echo "hostname=$(hostname)" >> MANIFEST.meta
  echo "host_id=$(cat /etc/machine-id 2>/dev/null || echo unknown)" >> MANIFEST.meta
)

if gpg --list-secret-keys "$GPG_KEY_ID" >/dev/null 2>&1; then
  gpg --batch --yes --detach-sign --armor \
    --local-user "$GPG_KEY_ID" \
    -o "$WORK/MANIFEST.sha256.asc" \
    "$WORK/MANIFEST.sha256"
fi

# --- Push to object store ---
echo "==> Push to ${BUCKET}/${DATE}/"
aws s3 sync "$WORK" "${BUCKET}/${DATE}/" \
  --storage-class STANDARD_IA \
  --only-show-errors

# --- Retention housekeeping (local only — object store retention is lifecycle-managed) ---
find /var/lib/soc2-evidence -maxdepth 1 -type d -mtime "+${RETENTION_DAYS}" \
  -exec rm -rf {} \; 2>/dev/null || true

echo "==> [$TS] DONE — pushed $(find $WORK -type f | wc -l) artifacts"

Set the systemd timer to fire daily at 03:15 UTC after the nightly backup, and pin the object-store bucket to versioned + object-lock so a compromised host cannot rewrite history.

cat > /etc/systemd/system/soc2-evidence.service <<'UNIT'
[Unit]
Description=SOC 2 daily evidence collection
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/soc2-evidence-collect.sh
Nice=10
IOSchedulingClass=best-effort
IOSchedulingPriority=7
UNIT

cat > /etc/systemd/system/soc2-evidence.timer <<'UNIT'
[Unit]
Description=Daily SOC 2 evidence collection at 03:15 UTC

[Timer]
OnCalendar=*-*-* 03:15:00 UTC
Persistent=true
RandomizedDelaySec=15m

[Install]
WantedBy=timers.target
UNIT

systemctl daemon-reload
systemctl enable --now soc2-evidence.timer

When the auditor’s sample request lands — “evidence for CC6.1 on 2026-03-14, 2026-03-22, 2026-04-08” — the response is aws s3 ls s3://acme-soc2-evidence/2026-03-14/access/, drop the signed bundle into the auditor’s secure share, and move on. That is what evidence collection on a Linux-VM stack looks like when it is built right.

Run your SOC 2-bound Linux-VM stack under Managed Cloud Ops with evidence collection wired into the operating cadence — or scope a SOC 2 infrastructure-readiness sprint if your observation window is opening soon.