Metadata-Version: 2.4
Name: keywarden-ssh
Version: 0.5.0
Summary: Check SSH posture around the public keys you push. Never stores them.
Author: Michael Waxman
License-Expression: MIT
Project-URL: Homepage, https://github.com/generalwax2018/keywarden
Project-URL: Repository, https://github.com/generalwax2018/keywarden
Project-URL: Issues, https://github.com/generalwax2018/keywarden/issues
Project-URL: Changelog, https://github.com/generalwax2018/keywarden/blob/main/CHANGELOG.md
Keywords: ssh,security,authorized_keys
Classifier: Environment :: Console
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Security
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Keywarden

Check SSH posture around the public keys you already push. Keywarden does not push keys, and it does not store them.

You keep using whatever already places `authorized_keys` on a machine (Ansible, a script, by hand). Keywarden reads the effective daemon config and the keys that are actually authorized, fingerprints those keys, and drops the bodies before it writes a report.

One command checks this machine, one host, or every host in an Ansible inventory. It is a point-in-time check: there is no daemon, scheduler, or stored state.

![keywarden ui: run checks on six lab hosts, review keys that reach root or have gone stale, and find every place a key still works](https://raw.githubusercontent.com/generalwax2018/keywarden/main/docs/screenshots/demo.gif)

`keywarden ui` on the built-in lab hosts. Screenshots: [findings, light](https://raw.githubusercontent.com/generalwax2018/keywarden/main/docs/screenshots/findings-light.webp) · [findings, dark](https://raw.githubusercontent.com/generalwax2018/keywarden/main/docs/screenshots/findings-dark.webp) · [access review](https://raw.githubusercontent.com/generalwax2018/keywarden/main/docs/screenshots/access-review.webp).

## Try it in a minute

```sh
pip install keywarden-ssh
keywarden ui
```

Your browser opens Keywarden. Press **Use Lab Keys**, then **Run Checks**, to see six made-up hosts with the kinds of problems real fleets have: a former employee's key on a shared admin account, a contractor key nobody uses, a root key that works from anywhere. Nothing is sent anywhere and nothing is stored. Then point it at a real host with **One host**.

## Install

Python 3.9 or newer. No third-party packages. Keywarden checks Linux, macOS, and FreeBSD servers. `--local` needs a POSIX system; the browser UI, `--host`, and `--inventory` also run on Windows using its built-in `ssh`. There is also a [container image](#github-action-and-container) and a [GitHub Action](#github-action-and-container).

```sh
python3 -m pip install keywarden-ssh
```

Or straight from a tag:

```sh
python3 -m pip install "git+https://github.com/generalwax2018/keywarden.git@v0.5.0"
```

The distribution name is `keywarden-ssh`. The `keywarden` package on PyPI is an unrelated project; do not install it expecting this tool.

Or clone this repository and run it from the tree:

```sh
git clone https://github.com/generalwax2018/keywarden.git
cd keywarden
PYTHONPATH=src python3 -m keywarden --version
```

## Use it in a browser

```sh
keywarden ui
```

This opens Keywarden in a browser tab, served from your machine. Paste the public keys you push, choose what to check (this machine, one host, an Ansible inventory, or collector output you paste), and run. Results show failing hosts first, with the access review table and a "find a key" search beside them. Export the findings as JSON or the key table as CSV. Press **Use Lab Keys** and **Run Checks** to try it on six made-up hosts first; the lab also loads example owners and two leavers, so the **Access Review** tab shows names and the sign-off.

The server listens on `127.0.0.1` only, on port 8765 (or any free port if that one is taken), and the link it prints carries a one-time token. It refuses requests without that token, from another web page, or with a Host header other than localhost, so a site you visit cannot drive it. The page loads nothing from the internet. Key text is fingerprinted on arrival and cleared from the box; the tab holds fingerprints only. Use `--port` to pick the port and `--no-browser` to print the link without opening it.

The page remembers your settings (what to check, paths, day counts) and a summary of each host's last results (check codes, results, and fingerprints) in this browser, so the next run shows **Since your last run: 2 new, 1 cleared** and marks each change. Keys, collector output, and the "trust new host keys" switch are never remembered. **Forget** in the sidebar clears it.

## Check this machine

```sh
keywarden check --local --allow team.pub
```

`team.pub` is the public keys you intend to be authorized, one OpenSSH line each. Keywarden fingerprints them for the comparison and does not copy them into the report.

A failing check exits 1. A clean or warning-only check exits 0. Bad input, including a private key, exits 2 and writes no report.

The terminal shows a summary line, then failures and warnings in colour. Passing checks are counted but hidden; `--verbose` lists them. Colour is off when the output is not a terminal or `NO_COLOR` is set, and `--color always|never` overrides it.

```sh
keywarden check --local --allow team.pub --output keywarden-report.json
```

The JSON file has fingerprints, key types, bit lengths, comments, daemon settings, and findings. It does not have key bodies. Do not point `--allow` at a private key. If one is present, Keywarden stops and keeps nothing.

## Check one other host

```sh
keywarden check --host deploy@app-web-03.example --allow team.pub --json
```

This is `ssh` in batch mode (no password prompt). The remote command prints `sshd -T` and `authorized_keys` back to this process. Fingerprints are computed here. Nothing is written on the remote host.

A host key that is missing or changed fails the connection. Keywarden does not accept it. `--accept-new` trusts a key you have not seen before and is off unless you pass it. Use the `known_hosts` file your SSH client already has.

Reading root, and reading other accounts, needs to be allowed: run as root, or have passwordless `sudo`. With general passwordless sudo the collector uses it for `sshd -T`, `stat`, `test`, `ls`, `grep` of the sshd config, and `cat` of `authorized_keys`. With sudo limited to `sshd -T` and `cat`, those two still work, and file modes behind an unreadable home are reported as unknown. If root's file cannot be read, the root-key check is a **warning, not a pass**. A hidden root key must not look clean, and an account whose home cannot be read is listed as not checked instead of being skipped.

Every line read from an `authorized_keys` file is prefixed before it crosses the wire, and the parser refuses output that is out of order, repeated, or truncated. A user who writes collector markers into their own key file cannot change what the report says about the daemon or other accounts; the host fails with `collector-output` instead.

`--account` adds a specific user. Repeat it. Accounts that already have an `authorized_keys` file are included when the file is visible.

## Check an Ansible inventory

```sh
keywarden check --inventory hosts.ini --allow team.pub
```

`--inventory` takes the inventory you already use:

- **INI** files are read directly.
- **YAML**, inventory plugins (AWS, Azure, GCP, and others), dynamic inventory scripts, and inventory directories are handed to `ansible-inventory --list`, so Ansible resolves them exactly as it would for a playbook. That needs Ansible installed where Keywarden runs; without it, Keywarden says so.
- **JSON** from `ansible-inventory -i <anything> --list > inventory.json` is read directly, so Ansible does not have to be installed on the machine running Keywarden.

From an INI file, Keywarden reads `ansible_user`, `ansible_host`, `ansible_port`, and `ansible_ssh_private_key_file` (and their `ansible_ssh_*` spellings), from host lines, `[group:vars]`, and parent groups through `[group:children]`. A nearer group overrides a parent, and a host line overrides both, as in Ansible. A private-key path is handed to `ssh -i`; Keywarden never opens the file. Passwords, become passwords, and every other variable are dropped as the file is read. From JSON, Ansible has already merged those variables into each host. Hosts are checked eight at a time by default (`--jobs 1` to `--jobs 32`), each over its own SSH session, and reported in inventory order. A host that cannot be reached is a failure, and the rest are still checked.

The terminal shows failures only. A check that names a key is printed once per fingerprint, with every host where that fingerprint failed. Other failures stay on their own line: hostname and check. Passes are not printed. Exit 1 if any host failed. `--output` writes the JSON report, still without key bodies. The `fingerprints` array is the unique set. `--prior` takes the previous report from the same inventory, and marks drift host by host.

```ini
[web]
app-web-03 ansible_user=deploy
bastion ansible_host=10.0.0.9 ansible_user=ops ansible_port=2222
```

There is no scheduler. The next run is the next time you start the command.

## What is checked

| Code | Fails when |
| --- | --- |
| `permit-root` | `PermitRootLogin` is anything but `no`. `prohibit-password` and `without-password` still allow a root key, so they fail. |
| `password-auth` | `PasswordAuthentication` is on |
| `keyboard-interactive` | `KbdInteractiveAuthentication` is on |
| `empty-passwords` | `PermitEmptyPasswords` is on |
| `pubkey-auth` | `PubkeyAuthentication` is off |
| `root-authorized-key` | root has a key. Unreadable is a warning. |
| `root-account` | another account has uid 0, root is missing, or root's password field is empty |
| `permissions` | `.ssh` or `authorized_keys` is group- or world-accessible |
| `weak-algorithm` | DSA, or RSA under 3072 bits |
| `outside-push` | a non-root key is not in `--allow` |
| `cert-authority` | a line is marked `cert-authority`, unless that CA is in `--allow-ca` |
| `ssh-certificate` | a certificate is expired, not yet valid, a host certificate, unreadable, or signed by a CA not in `--allow-ca`. A warning when it is valid for longer than `--max-cert-days` (default 90), never expires, or names no principals. |
| `host-certificate` | the host's own certificate (`HostCertificate`) has expired or is signed by a CA not in `--allow-ca`. A warning when it never expires or expires within 14 days. |
| `accepted-algorithms` | `PubkeyAcceptedAlgorithms` still allows `ssh-rsa`, `ssh-dss`, or SHA-1 |
| `ca-algorithms` | `CASignatureAlgorithms` still allows those |
| `trusted-user-ca` | `TrustedUserCAKeys` is set, so a signed key can bypass the push. With `--allow-ca`, it passes when every CA in that file is approved. |
| `revoked-keys` | a user CA is trusted and `RevokedKeys` is none (warning) |
| `authorized-keys-command` | a command can inject keys that are not in the file |
| `authorized-keys-file` | `sshd` also reads a path other than `.ssh/authorized_keys` |
| `hostbased-auth` | host-based authentication is on |
| `auth-methods` | `AuthenticationMethods` still allows a password |
| `sshd-config` | `sshd -T` could not run, so daemon checks were skipped (warning) |
| `match-blocks` | `sshd_config` has `Match` blocks (warning; see below) |
| `collector-output` | the collector output was malformed or tampered with |
| `unreachable` | an inventory host could not be reached |
| `key-to-root` | a key opens an account with passwordless root: `NOPASSWD` sudo to a shell or `ALL`, or a root-equivalent group such as `docker` (warning) |
| `key-source` | a root-level key has no `from=` restriction (warning) |
| `forced-command-forwarding` | a `command=` key still allows port or agent forwarding (warning) |
| `key-environment` | a key sets `environment=` and `PermitUserEnvironment` is on |
| `expired-key` | a line's `expiry-time` has passed, or cannot be read (warning) |
| `log-level` | `LogLevel` is `QUIET`, `FATAL`, or `ERROR`, so logins are not recorded |
| `auth-log` | the sshd log could not be read, so key usage was not checked (warning) |
| `stale-key` | an authorized key has no login in `--stale-days` (default 90). A warning when the logs are shorter than that. |
| `leaver-key` | with `--owners` and `--leavers`: a key belonging to someone who has left is still authorized |
| `key-owner` | with `--owners`: a key matches nobody in the owners file (warning) |
| `jump-host` | with `--require-jump`: Keywarden reached the host directly rather than through a jump host |

Fields that are absent from the observation are skipped, not treated as a pass.

`sshd -T` prints the default settings, before any `Match` block applies. When the config has `Match` blocks, Keywarden also runs `sshd -T -C user=root,...` and fails `permit-root`, `password-auth`, or `keyboard-interactive` if a block makes root worse than the default. A `Match` block can only make a result worse, never better. Blocks for other users, groups, or source addresses are not evaluated; `match-blocks` warns so you know to read them.

Key text is fingerprinted in memory and then dropped. A private key, including a PuTTY private key, stops the run and is not written. The report never contains a key body. `--allow` is not deleted; it is your file.

`forced-commands-only` is a warning. Pass `--no-weak` or `--no-outside` to skip those two comparisons.

Key comments are often an email address or a machine name. Pass `--redact-comments` to leave them out of the terminal output and the report.

## Access review

Every check also builds a table with one row per authorized key: host, account, fingerprint, type, comment, whether it is in `--allow`, what logging in leads to (`reach`), its `from=` and other options, and when it was last used.

```sh
keywarden check --local --allow team.pub --keys
keywarden check --inventory hosts.ini --allow team.pub --csv access-review.csv
```

`--keys` prints the table. `--csv` writes it for a spreadsheet or a ticket. The JSON report has it under `keys`. Cells that start with `=`, `+`, `-`, or `@` are prefixed with `'` so a key comment cannot run as a spreadsheet formula. A `command=` value is never printed, only that one is set, because forced commands sometimes carry tokens.

**Reach.** For each account with a key, Keywarden reads `sudo -l -U <account>` and the account's groups:

| Reach | Meaning |
| --- | --- |
| `root` | the account is root, or uid 0 |
| `root-nopasswd` | `NOPASSWD` sudo to `ALL`, a shell, or a command with a known shell escape (`vim`, `less`, `find`, `tee`, `systemctl`, and others), or membership in `docker`, `lxd`, `lxc`, `incus-admin`, or `disk` |
| `root-password` | the same sudo rules, but with a password; or membership in `sudo`, `wheel`, or `admin` when the rules cannot be read |
| `limited` | sudo to specific commands that are not on the shell-escape list. The list is not exhaustive; review these rules by hand. |
| `none` | not in sudoers, or sudo is not installed |
| `unknown` | sudo rules could not be read (run as root or with passwordless sudo) |

Each `sudo -l -U` call is written to the host's auth log by sudo itself.

**Last used.** Keywarden reads `Accepted publickey for <account> ... SHA256:<fingerprint>` lines. sshd writes these at the default `LogLevel INFO`. It prefers the systemd journal, read only for `ssh.service` and `sshd.service` entries logged as uid 0, which a local user cannot forge. Without a journal it reads `/var/log/auth.log*` or `/var/log/secure*`, including rotated and gzipped files. A local user can write fake lines to those files with `logger`, so the report names which source it used (`authLog`). The log tells you how far back it reaches; a key is only called stale when the logs cover the whole `--stale-days` window. A login through a certificate counts toward the `cert-authority` line that trusted it. A certificate pasted directly into `authorized_keys` is marked `unmatched`, because sshd logs the key inside it rather than the line.

Only the newest login line and a count per account and key leave the host. Pass `--redact-addresses` to drop the last login address from the output.

## Who owns each key, and who has left

A fingerprint is not an answer to "who can get in". Give Keywarden an owners file and every key gets a name:

```sh
keywarden check --inventory hosts.ini --owners owners.csv --leavers leavers.txt --keys
```

```csv
owner,email,github,fingerprint,status
Dana Ortiz,dana@example.com,dortiz,SHA256:i9/X7kZqpISKANQXHxfPGg8U32ooosWg6S4XoO75GPM,
Jordan Pike,jordan@example.com,,SHA256:Bp52GaHcgigUoEWMzWgfUk/2Rnaw5UXCf06Srz7c35M,terminated
```

`--owners` reads:

- **CSV** with an `owner` column and a `fingerprint` or `key` column (a public key line). Optional `email`, `github`, and `status`; a status of `left`, `terminated`, `disabled`, or `offboarded` marks a leaver.
- **JSON**: `{"owners": [{"name": ..., "email": ..., "github": ..., "fingerprints": [...], "keys": [...]}]}`.
- **LDIF** from your directory: `ldapsearch -LLL '(objectClass=ldapPublicKey)' uid mail sshPublicKey > people.ldif`.
- **A directory** of `<person>.pub` files, the layout many teams already keep in their Ansible repo.
- **GitHub**: a `github` username fetches `https://github.com/<user>.keys` (`--no-github` to skip).

Keys are fingerprinted as they are read and the bodies dropped. `--leavers` is one name, email, or GitHub username per line, the shape of an HR export. Any of their keys still authorized anywhere fails `leaver-key`, and a leaver with no keys on file is printed on stderr, because Keywarden cannot sweep keys it does not know about. Keys that match nobody warn as `key-owner`.

The access review table gains an `owner` column, the JSON report an `owners` summary (hosts, accounts, keys, and root reach per person), and the terminal a **who has access** list with leavers first.

## Sign off a review

A quarterly access review (PCI DSS 7.2.4, NERC CIP-004 R4.2 and R4.3) is a person deciding, key by key, that access is still right. In `keywarden ui`, open **Access Review**, mark each key **Approve** or **Revoke** with a note, enter your name, and press **Sign Off**. You get two files:

- `keywarden-review-<date>.json`: the decisions with owner, reach, and last use for each key, the reviewer, the SHA-256 of the report reviewed, and a SHA-256 seal over the record.
- `keywarden-review-<date>.html`: the same, for the auditor.

Add your SSH signature, and let anyone check it:

```sh
keywarden review sign keywarden-review-2026-11-18.json --key ~/.ssh/id_ed25519
keywarden review verify keywarden-review-2026-11-18.json --signers allowed_signers
```

Signing uses `ssh-keygen -Y sign` with the namespace `keywarden-review`; Keywarden never reads your private key. `verify` fails if a decision was changed after sealing, or if the signature does not match. Without the GUI, `keywarden review record report.json decisions.csv --reviewer "Dana Ortiz" --output review.json` seals decisions from a CSV (`host,account,fingerprint,decision,note`).

## Fix plan

Keywarden does not change hosts. It writes the change for you to review:

```sh
keywarden check --inventory hosts.ini --owners owners.csv --leavers leavers.txt --fix-plan keywarden-fix.yml
keywarden plan report.json --review keywarden-review-2026-11-18.json --output keywarden-fix.yml
```

The playbook removes keys by fingerprint: on each host, `ssh-keygen -lf` fingerprints every `authorized_keys` line and drops the matches, so no key body is in the playbook. `--fix-for` picks what goes in: `leaver`, `outside` (not in `--allow`), `stale`, `unowned`, `expired` (default `leaver,outside`); with `--review`, the keys marked **Revoke**. **Fix Plan** in the GUI does the same from your decisions.

```sh
ansible-playbook -i hosts.ini keywarden-fix.yml                         # dry run: lists what matches
ansible-playbook -i hosts.ini keywarden-fix.yml -e keywarden_apply=true  # removes, after a backup
```

Each file is backed up as `authorized_keys.keywarden-<time>` before it is rewritten, with its owner and mode kept.

## Alerts

```sh
keywarden check --inventory hosts.ini --allow team.pub --prior last.json --output last.json \
  --notify "$SLACK_WEBHOOK"
```

`--notify` posts a short summary when something changed since `--prior` (new or regressed findings, new keys): host, check, and fingerprints, never comments or login addresses. `--notify-on fail` posts whenever a host fails, and `always` on every run. The message shape follows the URL (Slack, Discord, Teams workflow) or `--notify-format`; anything else gets plain JSON. Set `KEYWARDEN_WEBHOOK` instead of passing the URL on the command line. Only `https://` URLs are accepted, plus `http://localhost` for testing.

## Certificates and jump hosts

`--allow-ca ca.pub` (repeatable) lists the user and host CAs you run. With it, `trusted-user-ca` compares the keys in sshd's `TrustedUserCAKeys` file with that list instead of failing whenever a CA is trusted; `cert-authority` lines and certificates in `authorized_keys` pass only when their CA is listed; and the host's own `HostCertificate` is checked for an approved signer and an end date. Certificates valid for longer than `--max-cert-days` (default 90), or forever, warn.

Hosts behind a bastion are reached the way Ansible reaches them: `ansible_ssh_common_args` with `-J`, `-o ProxyJump=`, or `-o ProxyCommand="ssh -W %h:%p bastion"`, or a `ProxyJump` in `~/.ssh/config`. `--jump` does the same for `--host`. Each host's report says how it was reached (`accessPath`). With `--require-jump`, a host Keywarden reached directly fails `jump-host`: evidence for NERC CIP-005 R2.1, if your rule is that interactive access goes through an intermediate system.

## Pipelines and SIEM

```sh
keywarden check --inventory hosts.ini --allow team.pub --sarif keywarden.sarif --jsonl keywarden.jsonl
```

`--sarif` writes SARIF 2.1.0. Upload it to GitHub code scanning and each finding becomes an alert on the inventory line for that host, with its controls as tags; alerts are deduplicated across runs by host, check, and fingerprints. In a scheduled workflow with `permissions: security-events: write`, on a runner that can reach your hosts:

```yaml
- run: pipx run --spec keywarden-ssh keywarden check --inventory inventory/hosts.ini --allow keys/team.pub --sarif keywarden.sarif || true
- uses: github/codeql-action/upload-sarif@v4
  with:
    sarif_file: keywarden.sarif
    category: keywarden
```

`--jsonl` writes one JSON object per line: a `finding` event for every check on every host, and a `key` event for every authorized key with its reach, usage, and last login. Fields are flat (`host`, `code`, `severity`, `fingerprints`, `controls`, and so on), so Splunk, Microsoft Sentinel, and Elastic can ingest the file as-is. Neither output contains key bodies.

## GitHub Action and container

The repository is a GitHub Action. On a self-hosted runner that can reach your hosts:

```yaml
permissions:
  contents: read
  security-events: write
steps:
  - uses: actions/checkout@v7
  - uses: generalwax2018/keywarden@v0.5.0
    with:
      inventory: inventory/hosts.ini
      allow: keys/team.pub
      owners: keys/owners.csv
      args: --require-jump --stale-days 60
```

It installs Keywarden from the tag you pin, runs the check, and uploads the SARIF to code scanning. Outputs: `sarif` and `exit-code`. Set `fail-on-findings: "true"` to fail the job when a host fails.

Or run the container, which has `ssh` and runs as a non-root user:

```sh
docker build -t keywarden .
docker run --rm -v "$PWD:/work" -v "$HOME/.ssh:/home/keywarden/.ssh:ro" keywarden \
  check --inventory hosts.ini --allow team.pub --sarif keywarden.sarif
```

`--build-arg ANSIBLE=1` adds `ansible-core` for YAML and dynamic inventories.

## Verify a release

Releases are built and published by GitHub Actions from a tag, with no stored PyPI token. Each release has:

- PyPI attestations (PEP 740), shown on the PyPI project page.
- A GitHub build-provenance attestation: `gh attestation verify keywarden_ssh-0.5.0-py3-none-any.whl --repo generalwax2018/keywarden`.
- The wheel, the source archive, and `SHA256SUMS` on the GitHub release.

The repository's own practices are scored weekly by [OpenSSF Scorecard](https://securityscorecards.dev/viewer/?uri=github.com/generalwax2018/keywarden).

## Evidence for an assessor

```sh
keywarden check --inventory hosts.ini --allow team.pub --waivers keywarden.toml --evidence ssh-evidence.html
```

`--evidence` (or **Evidence** in `keywarden ui`) writes one self-contained HTML file: who ran the check and with what visibility, the hosts in scope, every finding with the controls it bears on, the access review table, accepted risks, and a SHA-256 of the embedded JSON report so an assessor can tell it was not edited. A control coverage table groups the results under CIS Controls v8, NIST SP 800-53 Rev. 5, PCI DSS v4.0, and NERC CIP. Every finding in the JSON report also carries its `controls`.

The mapping is in [docs/compliance.md](docs/compliance.md). It supports an assessment and does not replace one: a passing check is evidence toward a control on the hosts checked, not proof the control is met.

## Find a key

Offboarding someone, or a laptop was stolen: find every place their key gets in.

```sh
keywarden where --key alice.pub --inventory hosts.ini
keywarden where SHA256:CU0yV+3RbcXlukC+M6dq938Ou+kt105Ipe/qaP4n4LU --host deploy@app-web-03.example
```

Each hit names the host, the account, whether the key is in `authorized_keys` or trusted as a `cert-authority`, its reach, its `from=` limit, and its last login. A key that logged in recently but is not in any readable `authorized_keys` is listed too: it may come from `AuthorizedKeysCommand`, another key file, or a file Keywarden could not read. Hosts and accounts that could not be read are printed on stderr, because "not found" only covers what was visible.

Like `grep`, `where` exits 0 when it finds the key, 1 when it does not, and 2 on bad input. A private key passed to `--key` is refused.

## Waivers

Some findings are deliberate: a break-glass key on root, an admin account with passwordless sudo. Record them instead of turning the check off:

```toml
# keywarden.toml (Python 3.11+), or the same fields as JSON: {"waivers": [ {...} ]}
[[waiver]]
code = "root-authorized-key"
host = "bastion-*"                # optional glob; default every host
fingerprint = "SHA256:..."        # optional; default every key in the finding
reason = "break-glass key, sealed in the vault"
owner = "secops"                  # owner or ticket is required
ticket = "SEC-1234"
expires = "2027-03-01"            # required
```

```sh
keywarden check --inventory hosts.ini --allow team.pub --waivers keywarden.toml
```

A waived finding is reported as `accepted`, with the reason, ticket, and end date, and does not fail the run. When a finding names several keys, it is accepted only if every key is waived; otherwise it keeps its severity and says which keys were waived. An expired waiver stops working and the finding says so. A waiver that matched nothing is printed on stderr so the file does not collect dead entries.

## Drift

Keep the previous report (it has no key bodies) and pass it next time:

```sh
keywarden check --local --allow team.pub --prior keywarden-report.json
```

A check that was a pass and is now a fail is marked `regressed`. A new failure is `new`. A failure that cleared is `cleared`. A check that was already failing and now names a fingerprint it did not name before is `new-keys`, with the added fingerprints in `newFingerprints`. Each finding that names keys carries a `fingerprints` array.

## Offline observation

If you would rather not have Keywarden open SSH itself, run the collector on the host and pipe it. Do not save that stream: it contains public keys. The report does not. Collector output from 0.1.0 (protocol 1) is refused; run the current collector. Output from 0.2.0 to 0.4.0 still reads, without the certificate files that `trusted-user-ca` and `host-certificate` compare.

```sh
python3 -c 'from keywarden.collect import REMOTE_SCRIPT; print(REMOTE_SCRIPT)' | sh | keywarden check --observation - --allow team.pub
```

## What this release does not do

- It does not install, rotate, or delete keys itself. A fix plan is a playbook you review and run.
- It does not remember a push, a host list, or a report unless you choose `--output`.
- It does not run on a schedule or keep evidence for you. Run it from cron, CI, or the GitHub Action, and keep the reports and review records you want.
- It checks up to 2,000 inventory hosts per run, 32 at a time at most.
- It reads `/etc/passwd` (Directory Services on macOS) and `~/.ssh/authorized_keys`. Accounts that exist only in LDAP or SSSD, and keys served by `AuthorizedKeysCommand`, are not listed (the command itself is flagged). Their logins still show up in `where`.

## Tests

```sh
python3 -m unittest discover -s tests -v
```

Fingerprint and certificate tests run when `ssh-keygen` is installed and are skipped otherwise. CI runs the tests on Linux (Python 3.9 to 3.13), Windows, and macOS; runs the collector against a real OpenSSH server, including an `authorized_keys` file that tries to rewrite the report; runs the collector on a real Mac and a FreeBSD VM; builds the container; and runs the GitHub Action.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). Report security issues privately; see [SECURITY.md](SECURITY.md).

## License

[MIT](LICENSE).
