russh
Async Rust SSH client and server library on Tokio, with post-quantum hybrid key exchange, OpenSSH certificates, and agent forwarding.
Repository Health
Technical Analysis
russh is a low-level, asynchronous SSH2 client and server implementation for Rust, built on Tokio and futures. It is a fork of the original Thrussh project that adds substantial protocol coverage: local and remote TCP/IP and Unix-socket forwarding, a wide range of ciphers, key exchanges (including the post-quantum hybrid mlkem768x25519-sha256), MACs, OpenSSH host and user certificates, keepalive handling, agent forwarding channels, and PPK/Pageant key support on Windows.
Applications embed russh by implementing its client::Handler or server::Handler traits and driving channels that expose AsyncRead/AsyncWrite interfaces, giving full control over authentication, session multiplexing, and I/O without shelling out to an external ssh binary. It ships as a Cargo workspace alongside companion crates (russh-cryptovec for zeroizing sensitive buffers, russh-config, russh-util), and is used as the SSH engine inside several production tools, including the warpgate bastion and Devolutions Gateway.
What You Get
- Async
client::Handlerandserver::Handlertraits for building SSH clients and servers directly in Rust, withAsyncRead/AsyncWritechannel handles for exec, PTY, and SFTP-style subsystems - A wide negotiated algorithm surface: modern and legacy ciphers (chacha20-poly1305, AES-GCM/CTR/CBC variants, 3des-cbc), key exchanges from classic Diffie-Hellman/ECDH through the post-quantum hybrid
mlkem768x25519-sha256, and multiple MAC/ETM variants - OpenSSH-compatible certificate authentication for both host and user keys, plus OpenSSH strict key-exchange and
server-sig-algsextension support - Local and remote port forwarding (
direct-tcpip/forward-tcpip) and Unix-domain-socket forwarding (direct-streamlocal/forward-streamlocal) - Pluggable crypto backends (
aws-lc-rsby default, orring), SSH agent forwarding channels, PPK key format support, and Windows Pageant agent integration - Companion
russh-cryptoveccrate for zeroizing/mlock-protected sensitive memory buffers used throughout key and secret handling
Common Use Cases
- Embedding an SSH client into a Rust CLI or automation tool to run remote commands, stream interactive PTY sessions, or transfer files without spawning an external
sshprocess - Building an SSH-facing bastion, jump host, or reverse-tunnel/port-forwarding proxy that terminates and re-establishes SSH connections in-process
- Implementing a custom SSH server that exposes a non-shell service (a TUI game, an admin console, a Kubernetes terminal) directly over the SSH transport
- Adding SFTP client or server support to a Rust application via the companion
russh-sftpcrate layered on russh’s channel primitives - Providing SSH-based remote access to a virtual machine, container, or embedded device manager where the host application already runs an async Rust/Tokio runtime
Under The Hood
Architecture
The crate’s entry point (src/lib.rs) re-exports client and server modules built around a shared connection state machine in src/session.rs (transport framing, packet buffering via sshbuffer.rs/ssh_read.rs, and key-exchange/rekey handling). Both client/mod.rs and server/mod.rs implement large Handler traits that applications fill in, delegating protocol-message dispatch to matching encrypted.rs and kex.rs submodules. Algorithm negotiation is centralized in negotiation.rs, which enumerates every supported cipher (cipher/), key-exchange method (kex/ — classic DH, curve25519, ECDH NIST curves, and the post-quantum hybrid ML-KEM), MAC (mac/), and host-key format (keys/) and owns the contract those pluggable modules implement against. Channels are tracked through channels/mod.rs and exposed to callers as AsyncRead/AsyncWrite handles via channel_stream.rs. This is a layered, modular design: a transport/session core sits beneath pluggable crypto-primitive modules, which in turn back the client/server handler traits and the channel abstraction applications interact with directly.
Tech Stack
Built for the 2024 Rust edition (minimum Rust 1.85) on Tokio as the async runtime, with a pluggable crypto backend — aws-lc-rs by default or ring as an alternative — layered over RustCrypto primitives (aes, sha1/sha2, hmac, curve25519-dalek, ed25519-dalek, p256/p384/p521, rsa, and ml-kem for the post-quantum hybrid key exchange). SSH key parsing and encoding are delegated to the ssh-key/ssh-encoding crates. The workspace bundles its own russh-cryptovec crate (a zeroizing, mlock-backed buffer type used for sensitive key material, isolating the crate’s unsafe code) and russh-util, plus an optional Windows-only pageant crate for Pageant agent support. Compression is optional via flate2, and the whole workspace is published to crates.io as five separate member crates.
Code Quality
Tests are pervasive rather than centralized: dozens of source modules (session, negotiation, cipher, kex, and key modules among them) carry inline #[test]/#[tokio::test] cases, complemented by eight dedicated integration test files under russh/tests/ exercising real protocol scenarios such as strict-kex rekeying, ML-KEM key exchange, channel backpressure, and connection contention. Error handling is explicit and typed throughout via thiserror::Error enums rather than panics, reinforced at the crate root by #![deny(clippy::unwrap_used, clippy::expect_used, clippy::indexing_slicing, clippy::panic)] with only manually reviewed exceptions. CI runs cargo fmt --check, cargo clippy -D warnings for both default and all-features builds, and cargo test (including all-features) on every push, including a Windows runner for the Pageant integration path.
What Makes It Unique
Beyond being a ground-up async Rust SSH2 implementation, russh stands out for shipping the post-quantum hybrid mlkem768x25519-sha256 key exchange well ahead of most SSH libraries, alongside OpenSSH certificate-based authentication, OpenSSH strict key exchange, agent-forwarding channels, and native Windows Pageant agent support — a combination rarely found together in pure-Rust network protocol crates. Its crate-level ban on panicking operations is an unusually strict safety bar for a protocol implementation, and it is proven in production as the SSH engine behind several deployed systems, including the warpgate bastion and Devolutions Gateway’s web-based SSH client.
Used by 2 apps in this directory
OpenShell
AI Agents · Developer Tools
The safe, private runtime that lets autonomous AI agents operate in sandboxed environments governed by declarative YAML policies — blocking data exfiltration, credential leaks, and unauthorized network activity before they happen.
Vibe Kanban
AI Agents · AI Code Assistants · Project Management
A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.