sshpubkeys
SSH public key parser
What it is and what it does
sshpubkeys is a native Python parser for OpenSSH public keys that validates and extracts metadata from ssh-rsa, ssh-dss, ssh-ed25519, and NIST-curve ecdsa keys. It depends on cryptography and ecdsa for the underlying cryptographic operations. The package provides a simple API: instantiate an SSHKey object with a key string, call parse(), and access properties like bits, comment, and hash methods (MD5, SHA256, SHA512). It also includes an AuthorizedKeysFile class for bulk parsing of authorized_keys files.
The package operates in two modes: strict (default), which enforces OpenSSH's own validation rules (e.g., DSA keys must be 1024, 2048, or 3072 bits), and loose, which attempts to accept any key OpenSSH would. It raises specific exceptions for different failure modes—InvalidKeyError for malformed data, NotImplementedError for unsupported key types, and InvalidOptionsError for invalid SSH options. The last release was in February 2021, and the project is dormant; however, the repository remains unarchived and may receive maintenance if issues arise.
Use it for:
- Validate SSH public keys before storing them in an authorized_keys file or database.
- Parse and audit authorized_keys files to extract key metadata and compute fingerprints for security logging.
- Build SSH key management tools that need to identify key type, bit length, and detect weak keys.
- Integrate SSH key validation into deployment or provisioning scripts that accept user-provided keys.
- Generate SHA256 or SHA512 fingerprints for SSH keys to match against known-hosts or key registries.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and validates OpenSSH public keys, extracting key type, bit length, and computing cryptographic hashes for ssh-rsa, ssh-dss, ssh-ed25519, and NIST-curve ecdsa keys.
Yes, if you need to parse and validate OpenSSH public keys in Python. The package is stable, has low install friction, carries a permissive license, and has no known vulnerabilities. Dormancy is a minor concern—the last release was over 2017 days ago—but the unarchived repository and broad Python 3 support (3.5+) suggest it remains usable for standard key formats. Install it if your use case is straightforward key parsing; consider alternatives if you need support for newer OpenSSH certificate formats or active maintenance.
Install
sshpubkeys on PyPI
pip
pip install sshpubkeysuv
uv add sshpubkeyspoetry
poetry add sshpubkeysInstalling sshpubkeys
Before you install
Low friction install with two stable runtime dependencies (cryptography and ecdsa). Package is dormant—last release was 2021-02-04, over 2017 days ago—but the repository remains active and unarchived, suggesting maintenance may resume if needed.
License in practice
BSD license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install sshpubkeys
from sshpubkeys import SSHKey
ssh = SSHKey("ssh-rsa AAAAB3NzaC1yc2E...", strict=True)
ssh.parse()
print(ssh.bits, ssh.hash_sha256())
Requires Python 3 (minimum version >=3); DSA keys must be 1024, 2048, or 3072 bits in strict mode.
Verify before relying
- Whether the package handles modern OpenSSH key formats (e.g., ssh-ed25519-cert-v01@openssh.com) or only the base key types listed.
- Performance characteristics when parsing large authorized_keys files with thousands of entries.
- Whether dormancy affects compatibility with recent OpenSSH releases or cryptographic best practices.
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — cryptography, ecdsa |
| Maintenance | dormant — 2,017 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,401,982/month — #3,948 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sshpubkeys-3.3.1-py2.py3-none-any.whl
Keywords: ssh, pubkey, public, key, openssh, ssh-rsa, ssh-dss, ssh-ed25519
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
asyncsshAsyncSSH provides an asynchronous SSH client…
copyleft · top 5,000 on PyPI
ssh-import-idssh-import-id fetches public SSH keys from…
copyleft · top 15,000 on PyPI
PGPyPGPy implements OpenPGP (RFC 4880) in pure…
permissive · top 5,000 on PyPI
sslcryptoProvides AES, ECIES, and ECDSA cryptographic…
unclear · top 15,000 on PyPI
M2CryptoM2Crypto wraps OpenSSL via SWIG to provide…
permissive · top 15,000 on PyPI
lightdsaLightDSA provides digital signature generation…
permissive · top 15,000 on PyPI
PGPy13PGPy13 is a Python library for OpenPGP…
permissive · top 15,000 on PyPI
ecdsaPure-Python implementation of ECDSA, EdDSA, and…
permissive · top 1,000 on PyPI
pure25519Pure-Python implementation of Curve25519 and…
permissive · top 15,000 on PyPI
slip10Implements SLIP-0010 hierarchical deterministic…
permissive · top 15,000 on PyPI