ssh-key

A pure Rust implementation of SSH key, certificate, and signature file formats.

Library
Cargo
v0.7.0-rc.11
243stars
Apache-2.0 OR MIT

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
70/100Good
Development Activity88
Maintenance52
Community60
Maturity52
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture84
Code Quality85
Innovation78
Learning Curve68

ssh-key is a pure Rust library for decoding and encoding SSH key file formats as described in RFC4251/RFC4253 and OpenSSH’s key formats, along with sshsig signatures and certificates (including certificate validation and certificate-authority support). It also handles authorized_keys and known_hosts file formats.

As part of the RustCrypto/SSH workspace, it builds on ssh-encoding and ssh-cipher for the lower-level codec and cipher primitives, and supports a wide range of key algorithms — Ed25519, RSA, ECDSA (P-256/P-384/P-521), and legacy DSA — behind feature flags, with optional no_std support for constrained environments.

What You Get

  • Decoders/encoders for OpenSSH private and public key formats (RFC4251/RFC4253)
  • SSH certificate support, including certificate validation and certificate-authority signing
  • sshsig detached signature creation and verification
  • authorized_keys and known_hosts file format parsing
  • Pluggable algorithm support behind feature flags: Ed25519, RSA, ECDSA (P-256/P-384/P-521), and DSA
  • Optional no_std/alloc-only builds for embedded and constrained targets

Common Use Cases

  • Building SSH server or client tooling that needs to read/write OpenSSH key files
  • Implementing a certificate authority that issues and validates SSH certificates
  • Verifying sshsig signatures (e.g. for signed Git commits or file attestation)
  • Parsing authorized_keys or known_hosts files in infrastructure automation
  • Generating new SSH keypairs programmatically without shelling out to ssh-keygen

Under The Hood

Architecture ssh-key is one of five crates in the RustCrypto/SSH Cargo workspace (ssh-cipher, ssh-derive, ssh-encoding, ssh-key, ssh-protocol), and depends on ssh-encoding for the low-level SSH wire-format codec and ssh-cipher for symmetric encryption of private keys. Within the crate, src/ splits cleanly by concern: algorithm/ for algorithm identifiers, private/ and public/ for the two key kinds, certificate/ for CA-signed certificates, fingerprint/ for key fingerprinting, plus top-level modules for sshsig.rs, authorized_keys.rs, known_hosts.rs, and ppk.rs (PuTTY key format). Tech Stack Targets Rust edition 2024 (rust-version 1.85), with algorithm implementations pulled in as optional dependencies behind Cargo feature flags — ed25519-dalek, rsa, p256/p384/p521, dsa — so consumers only compile the crypto they use; zeroize is threaded through for secret-wiping and no_std/alloc-only builds are supported via feature gating. Code Quality Each public module has a matching integration test in tests/ (e.g. certificate.rs, certificate_builder.rs, sshsig.rs, known_hosts.rs, private_key.rs), and the workspace shares lint configuration ([lints] workspace = true) across all five crates for consistent style enforcement. API Design The crate exposes ergonomic top-level types (PrivateKey, PublicKey, Certificate) with builder-style construction and format-native to_openssh()/from_openssh() round-trip methods, so consumers rarely need to touch the underlying wire encoding directly; the feature-flag-per-algorithm design keeps the default build lean while still surfacing a consistent API regardless of which algorithms are enabled.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search