# rsa2048-inventory A Bash script that makes an inventory of RSA-2048 usage on a Linux server. ## What it looks for | Area | Coverage | |---|---| | Files | Certificates, certificate requests, private and public keys in PEM (including blocks inside configuration files), DER, and PKCS#12 with an empty passphrase | | Signatures | Certificates and revocation lists signed with RSA-2048, even where their own key is of another type | | SSH | Host, user, `authorized_keys` and `known_hosts` keys, host keys offered, and logins in the system journal | | DKIM and DNSSEC | Published records, matched to local DKIM private keys, and DNSSEC key files | | OpenPGP | Keys and keyrings | | Live listeners | TLS and STARTTLS on TCP, and QUIC on selected UDP ports, with default and RSA-only handshakes | ## Requirements - Bash 4.4 or later, OpenSSL 3.0 or later, OpenSSH client tools, GNU findutils, grep and coreutils, and awk. - `sudo`, unless run as root. - Optional: `ss` (iproute2), `gpg`, `dig` and `journalctl`. Without them, the matching checks are limited or skipped. - QUIC probes need OpenSSL 3.2 or later. The script was written for Debian. Version 1.2.4 was run on eight Linux servers using OpenSSL 3.0.13, 3.0.22 and 3.5.9. ## Usage Check the download first. The SHA-256 of version 1.2.4 is: ``` 02f5101e47aaf28579489d02afe8254dc6fb1461e32febe6ad7313bd6d200e7e ``` ```bash sha256sum rsa2048-inventory.sh ``` Read the script, then run it as an ordinary user who can use `sudo` (preferred), or as root: ```bash bash rsa2048-inventory.sh ``` `--help` lists the options and `--version` shows the version. ## Privileges, network and logs - For an ordinary user, `sudo` is used only to list and read. Parsing runs as that user. - Run as root, `sudo` is not used and parsing also runs as root. - The script changes nothing outside its own report folder. Private keys are read through pipes and are not written to the report. - TLS, QUIC and SSH probes go only to listeners on the same host. They can amount to several hundred connections. - DNS queries go to the system resolver, for names in certificates whose private key is on the host, for the host name, and for DKIM selectors. - Probes and `sudo` calls appear in the host's logs. Run it only on systems you are authorised to assess. ## Output A new folder in the home directory holds: | File | Content | |---|---| | `summary.txt` | Counts, findings that matter most, certificate key types received from listeners, and what could not be inspected | | `inventory.tsv` | Every finding | | `live-certificates.tsv` | Every certificate received from a listener | | `unreadable.tsv` | Items that could not be inspected | | `notes.txt` | Notes from the run | **The report shows where keys are held. Treat it as confidential, and do not paste it into public issues.** Each finding has a class: | Class | Meaning | |---|---| | `live` | Seen in use or published | | `local` | Held on this host | | `backup` | In a backup copy | | `ca-bundle`, `trust-store`, `trust-copy` | Certificate authority certificates | | `package-trust` | Keys that verify packages and firmware | | `vendor-or-source` | Shipped with software, or test material | Classes are assigned from file paths and file contents, so check them before relying on them. ## Options Set these as environment variables. | Variable | Purpose | |---|---| | `ROOTS` | Directories to scan | | `OUT` | Report folder | | `INCLUDE_SOURCE=1` | Also scan source trees, test folders and package module caches | | `SNI_NAMES` | Names to use for probes and DNS queries | | `MAX_SNI` | Cap on names collected automatically (default 40) | | `BUNDLE_MIN` | Certificates in one file, with no private key, that mark it as a CA bundle (default 10) | | `SUMMARY_LINES` | Cap on finding lines in the summary (default 80) | | `QUIC_PORTS` | UDP port and ALPN pairs (default `443:h3 853:doq 8853:doq`) | | `SKIP_PROBES=1` | Do not connect to listeners | | `SKIP_DNS=1` | Do not query DNS | | `LOG_DAYS` | How far back to read SSH login records (default 90) | | `OPENSSL` | Path to the `openssl` binary (default: the one on `PATH`) | For example, to inspect files only: ```bash SKIP_PROBES=1 SKIP_DNS=1 bash rsa2048-inventory.sh ``` ## Limits An empty result is not proof of absence. The script does not cover: - QUIC on ports outside `QUIC_PORTS`, DTLS, or live IKE and OpenVPN handshakes. - Keys held only in databases, hardware or process memory. - The size or algorithm of most passphrase-protected keys, and Java keystores. - JSON-escaped PEM, files over 4 MB, other file systems mounted below a scanned directory, and outbound connections to other hosts. A configuration file that mentions a key is not proof that the key is in use: a later setting can override it. ## Known issue In version 1.2.4, the "Names probed or queried" line is blank, instead of showing "none", when no names are found. ## Licence MIT. Copyright (c) 2026 BeatQuantum Limited. See [LICENSE](LICENSE). The software is provided without warranty of any kind.