Skip to main content

ssh-keyaudit-lite: audit authorized_keys for weak SSH keys, read-only

ssh-keyaudit-lite helps with a quick audit of authorized_keys on one machine: it reads one authorized_keys file and prints, for every key, the SHA256 fingerprint (same format as ssh-keygen -lf), the key type, the key size in bits and the comment. It flags DSA keys, RSA keys below 3072 bits, keys with no comment, and lines that are not valid keys. It exits 1 when something is flagged, so it fits a cron job or a pre-check script. It never edits the file. One file, Python 3.9+ standard library only, MIT.

Need to audit a whole fleet, find keys reused across hosts, map keys to owners, or get a removal plan? That is the full SSH KeyAudit (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the All-Access Pass ($99, one payment).

  • Optional pip install, or just download the one file. No config, no state, no network access.
  • Reads one file (default ~/.ssh/authorized_keys, or a path you pass, or - for stdin). Nothing is written.
  • Understands authorized_keys options (from="...", command="...", no-pty, ...), comments, blank lines and OpenSSH certificates.
  • Fingerprints are computed in Python from the key data; no ssh-keygen needed.
  • Flags: --min-rsa-bits, --demo, --version. After pip install, use ssh-keyaudit-lite in place of python3 ssh_keyaudit_lite.py.

Real terminal demo of python3 ssh_keyaudit_lite.py --demo: it flags a weak RSA key, a key with no comment, a DSA key, and an invalid line.

Recorded on November 24, 2026 with asciinema + agg; real command and output, no simulated results. Recording source · Capture script.

Install

pip install ssh-keyaudit-lite
ssh-keyaudit-lite --help

Or download the single file (Python 3.9+, stdlib only, no extra packages):

curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/ssh-keyaudit-lite/main/ssh_keyaudit_lite.py
python3 ssh_keyaudit_lite.py --help

See the output first (offline demo)

python3 ssh_keyaudit_lite.py --demo
# ssh-keyaudit-lite 0.1.1: demo (built-in sample authorized_keys)
#
#   OK    line 2: 256 SHA256:ehngEyw0ibJhOPXM8qj4kHqp7PMOVB8whu2zTPeF2Dc alice@laptop (ED25519)
#   FLAG  line 3: 1024 SHA256:8r4r4yg1OcSAK7Bz9sMFslRJNPLryUYiOko0gbhQGOw bob@old-laptop (RSA)
#           - WEAK_RSA: RSA key is 1024 bits, below 3072
#   FLAG  line 4: 256 SHA256:qoGqsyZZLKieeTNmmTa5cxqEaRS0oE9CI9MpxJV+VpE no comment (ED25519)
#           - NO_COMMENT: no comment, so the key owner cannot be told from the file
#   FLAG  line 5: 1024 SHA256:1+DAnFbM29PkFgyIxsfhJPVm0c/YXZ4Zr1hP+xtf7qI legacy-ci (DSA)
#           - DSA_KEY: DSA keys are deprecated (disabled by default since OpenSSH 7.0, removed in OpenSSH 10.0)
#   FLAG  line 6: invalid line
#           - INVALID_LINE: invalid base64 key data (Only base64 data is allowed)
#
# 4 key(s): 1 OK, 3 flagged (1 DSA, 1 RSA < 3072 bits, 1 no comment); 1 invalid line(s).
# Read-only: the file was not changed.

The demo uses a built-in sample file with public test keys.

Audit your authorized_keys file

python3 ssh_keyaudit_lite.py                               # ~/.ssh/authorized_keys
python3 ssh_keyaudit_lite.py /home/deploy/.ssh/authorized_keys
sudo python3 ssh_keyaudit_lite.py /root/.ssh/authorized_keys
cat authorized_keys | python3 ssh_keyaudit_lite.py -       # stdin
python3 ssh_keyaudit_lite.py --min-rsa-bits 2048           # your own RSA threshold

The part after line N: is the same text ssh-keygen -lf prints for that key (<bits> SHA256:<fingerprint> <comment> (<TYPE>)), so you can match it against ssh-keygen -lf ~/.ssh/id_ed25519.pub on the client side.

What gets flagged

Finding Meaning
DSA_KEY ssh-dss key. DSA has been disabled by default since OpenSSH 7.0 and is removed in OpenSSH 10.0
WEAK_RSA RSA key smaller than --min-rsa-bits (default 3072, the same default as the full SSH KeyAudit)
NO_COMMENT Key without a comment, so you cannot tell from the file whose key it is
INVALID_LINE Line that is not a valid key: unknown type, bad base64, truncated key data, or a type that does not match the key data

Key types read: RSA, DSA, ECDSA (P-256/384/521), Ed25519, the FIDO sk- variants, and their OpenSSH certificates (the fingerprint shown for a certificate is the certified key's, as ssh-keygen -l does).

Exit codes for cron

Exit code Meaning
0 No findings (or no keys in the file)
1 At least one key or line was flagged
2 File not readable, or bad arguments
# crontab: check every Monday at 07:00, keep the last report
0 7 * * 1 python3 /opt/ssh_keyaudit_lite.py /home/deploy/.ssh/authorized_keys > /var/log/ssh-keyaudit-lite.txt 2>&1

Already using ssh-keygen -l?

ssh-keygen -lf already lists type, bits, SHA256 fingerprint and comment for every key in the file. It wins when that is all you need and OpenSSH is installed. This tool adds structured FLAG/OK findings — DSA, RSA below --min-rsa-bits (default 3072), missing comments, invalid lines — a cron exit code 1 on findings, and it does not need ssh-keygen. It is not a replacement for ssh-audit, which checks server/protocol config, not authorized_keys.

ssh-keyaudit-lite vs SSH KeyAudit

ssh-keyaudit-lite reads one local authorized_keys file and prints a plain-text list. That's it.

The full SSH KeyAudit scans a list of hosts through your own ssh client (it reads every readable authorized_keys on each host), finds the same key on several hosts, maps keys to owners from a simple owners file, flags offboarded and unknown owners and keys without restricting options, compares against the previous run, and writes a removal script that you review and run yourself. One-time payment, yours to keep. No subscription.

Lite is not a strict subset: the NO_COMMENT flag and the 0 / 1 exit code on findings are not in the paid tool.

Capability Lite (free) Paid SSH KeyAudit
One local authorized_keys file (or stdin) Yes Yes
SHA256 fingerprint, type, bits, comment Yes Yes
DSA keys, RSA below a threshold (default 3072) Yes Yes
Invalid lines reported Yes Yes
Keys without a comment Yes No
Fleet scan of many hosts through your own ssh (--hosts) No Yes
Same key reused across hosts No Yes
Owner mapping, offboarded / unknown owners (--owners) No Yes
Keys without restricting options (from=, command=, ...) No Yes
Diff against the previous run (--out-state, --diff) No Yes
Removal plan script you review and run (--out-plan, never run by the tool) No Yes
Output Plain text Text or JSON (--json)
Exit code 1 when something is flagged Yes No (exits 0 with findings)

Neither version edits authorized_keys files by itself.

Need the full version? SSH KeyAudit on PyForge: py-forge.com/products/ssh-keyaudit-fleet-key-inventory

Or get every PyForge tool, current and future, with the All-Access Pass ($99, one payment): py-forge.com/pass

Tests

python3 test_ssh_keyaudit_lite.py

The tests are offline. The fixture keys in fixtures/ are public keys generated with ssh-keygen (private halves discarded), with the recorded ssh-keygen -lf output. When ssh-keygen is installed the tests also compare against a live ssh-keygen -lf run.

License

MIT (this lite version). The full SSH KeyAudit is sold separately under its own license.

Metadata

Release files for ssh-keyaudit-lite 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssh-keyaudit-lite 0.1.1
File Size Uploaded Provenance Actions
ssh_keyaudit_lite-0.1.1.tar.gz 20.5 kB With provenance Details for ssh_keyaudit_lite-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ssh-keyaudit-lite 0.1.1
File Interpreter ABI Platform Actions
ssh_keyaudit_lite-0.1.1-py3-none-any.whl Python 3 none any Details for ssh_keyaudit_lite-0.1.1-py3-none-any.whl

Total release size: 32.0 kB

Release files / ssh_keyaudit_lite-0.1.1.tar.gz

Download URL ssh_keyaudit_lite-0.1.1.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6db1ac9da7df71b183b8661d8b29a0bc93a644894174373164287ce939844e97
BLAKE2b-256 checksum
How to use checksums
14b5798e037aefa9c3fa229aa0a4c495298b933b8897bd28f4692f98ab238362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / ssh_keyaudit_lite-0.1.1-py3-none-any.whl

Download URL ssh_keyaudit_lite-0.1.1-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d99cbefd0f260ae82c21ac13d441b69fe0ddc8d87b4afe745330b32c54ab232
BLAKE2b-256 checksum
How to use checksums
7a7927d258e18c609a905a02136bf5ff15dae17838949d16f56f0298db9fcfea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for ssh-keyaudit-lite 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ssh_keyaudit_lite-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page