# Russh

[![Rust](https://github.com/warp-tech/russh/actions/workflows/rust.yml/badge.svg)](https://github.com/warp-tech/russh/actions/workflows/rust.yml)  
[![All Contributors](https://img.shields.io/badge/all_contributors-75-orange.svg?style=flat-square)](#contributors-)


Low-level Tokio SSH2 client and server implementation.

> **Crypto backends:** enable at least one of the `aws-lc-rs` or `ring` features. `russh` fails to compile when both are disabled because a crypto backend is required.

Examples: [simple client](russh/examples/client_exec_simple.rs), [interactive PTY client](russh/examples/client_exec_interactive.rs), [server](russh/examples/echoserver.rs), [SFTP client](russh/examples/sftp_client.rs), [SFTP server](russh/examples/sftp_server.rs).

This is a fork of [Thrussh](https://nest.pijul.com/pijul/thrussh) by Pierre-Étienne Meunier.

> ✨ = added in Russh

* [More panic safety](https://github.com/warp-tech/russh#safety) ✨
* async traits ✨
* `direct-tcpip` (local port forwarding)
* `forward-tcpip` (remote port forwarding) ✨
* `direct-streamlocal` (local UNIX socket forwarding, client only) ✨
* `forward-streamlocal` (remote UNIX socket forwarding) ✨
* Ciphers:
  * `chacha20-poly1305@openssh.com`
  * `aes128-gcm@openssh.com` ✨
  * `aes256-gcm@openssh.com` ✨
  * `aes256-ctr` ✨
  * `aes192-ctr` ✨
  * `aes128-ctr` ✨
  * `aes256-cbc` ✨
  * `aes192-cbc` ✨
  * `aes128-cbc` ✨
  * `3des-cbc` ✨
* Key exchanges:
  * `curve25519-sha256@libssh.org`
  * `diffie-hellman-group-sha1` (GEX) ✨
  * `diffie-hellman-group1-sha1` ✨
  * `diffie-hellman-group14-sha1` ✨
  * `diffie-hellman-group-sha256` (GEX) ✨
  * `diffie-hellman-group14-sha256` ✨
  * `diffie-hellman-group16-sha512` ✨
  * `ecdh-sha2-nistp256` ✨
  * `ecdh-sha2-nistp384` ✨
  * `ecdh-sha2-nistp521` ✨
* MACs:
  * `hmac-sha1` ✨
  * `hmac-sha2-256` ✨
  * `hmac-sha2-512` ✨
  * `hmac-sha1-etm@openssh.com` ✨
  * `hmac-sha2-256-etm@openssh.com` ✨
  * `hmac-sha2-512-etm@openssh.com` ✨
* Host keys and public key auth:
  * `ssh-ed25519`
  * `rsa-sha2-256`
  * `rsa-sha2-512`
  * `ssh-rsa` ✨
  * `ecdsa-sha2-nistp256` ✨
  * `ecdsa-sha2-nistp384` ✨
  * `ecdsa-sha2-nistp521` ✨
* Authentication methods:
  * `password`
  * `publickey`
  * `keyboard-interactive`
  * `none`
  * OpenSSH certificates ✨
* Dependency updates
* OpenSSH keepalive request handling ✨
* OpenSSH agent forwarding channels ✨
* OpenSSH `server-sig-algs` extension ✨
* PPK key format ✨
* Pageant support ✨
* `AsyncRead`/`AsyncWrite`-able channels ✨

## Safety

* `deny(clippy::unwrap_used)`
* `deny(clippy::expect_used)`
* `deny(clippy::indexing_slicing)`
* `deny(clippy::panic)`
* Exceptions are checked manually

### Panics

* When the Rust allocator fails to allocate memory during a CryptoVec being resized.
* When `mlock`/`munlock` fails to protect sensitive data in memory.

### Unsafe code

* `cryptovec` uses `unsafe` for faster copying, initialization and binding to native API.

## Ecosystem

* [russh-sftp](https://crates.io/crates/russh-sftp) - server-side and client-side SFTP subsystem support for `russh` - see `russh/examples/sftp_server.rs` or `russh/examples/sftp_client.rs`.
* [async-ssh2-tokio](https://crates.io/crates/async-ssh2-tokio) - simple high-level API for running commands over SSH.

## Adopters

* [HexPatch](https://github.com/Etto48/HexPatch) - A binary patcher and editor written in Rust with terminal user interface (TUI).
  * Uses `russh::client` and `russh_sftp::client` to allow remote editing of files.
* [kartoffels](https://github.com/Patryk27/kartoffels) - A game where you're given a potato and your job is to implement a firmware for it
  * Uses `russh:server` to deliver the game, using `ratatui` as the rendering engine.
* [kty](https://github.com/grampelberg/kty) - The terminal for Kubernetes.
  * Uses `russh::server` to deliver the `ratatui` based TUI and `russh_sftp::server` to provide `scp` based file management.
* [lapdev](https://github.com/lapce/lapdev) - Self-Hosted Remote Dev Environment
  * Uses `russh::server` to construct a proxy into your development environment.
* [medusa](https://github.com/evilsocket/medusa) - A fast and secure multi protocol honeypot.
  * Uses `russh::server` to be the basis of the honeypot.
* [rebels-in-the-sky](https://github.com/ricott1/rebels-in-the-sky) - P2P terminal game about spacepirates playing basketball across the galaxy
  * Uses `russh::server` to deliver the game, using `ratatui` as the rendering engine.
* [warpgate](https://github.com/warp-tech/warpgate) - Smart SSH, HTTPS and MySQL bastion that requires no additional client-side software
  * Uses `russh::server` in addition to `russh::client` as part of the smart SSH functionality.
* [Devolutions Gateway](https://github.com/Devolutions/devolutions-gateway/) - Establish a secure entry point for internal or external segmented networks that require authorized just-in-time (JIT) access.
  * Uses `russh::client` for the web-based SSH client of the standalone web application.
* [Sandhole](https://github.com/EpicEric/sandhole) - Expose HTTP/SSH/TCP services through SSH port forwarding. A reverse proxy that just works with an OpenSSH client.
  * Uses `russh::server` for reverse forwarding connections, local forwarding tunnels, and the `ratatui` based admin interface.
* [Motor OS](https://github.com/moturus/motor-os) -  A new Rust-based operating system for VMs.
  * Uses `russh::server` as the base for its own [SSH Server](https://github.com/moturus/motor-os/tree/main/src/bin/russhd). 
* [Cubic VM](https://github.com/cubic-vm/cubic) - A lightweight command-line manager for virtual machines.
  * Uses `russh::client` and `russh_sftp::client` to access the virtual machine instances.
* [ferrissh](https://crates.io/crates/ferrissh) - An async SSH CLI scraper library for network device automation in Rust.
  * Uses russh::client for SSH transport, authentication, and interactive PTY sessions.
* [Yazi](https://github.com/sxyazi/yazi) - Blazing fast terminal file manager written in Rust, based on async I/O.
  * Uses `russh::client` to implement an async SFTP provider for remote file management.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

       Mihir Samdarshi
Mihir Samdarshi (https://github.com/mihirsamdarshi)
📖 (https://github.com/Eugeny/russh/commits?author=mihirsamdarshi)
       Connor Peet
Connor Peet (https://peet.io/)
💻 (https://github.com/Eugeny/russh/commits?author=connor4312)
       KVZN
KVZN (https://github.com/kvzn)
💻 (https://github.com/Eugeny/russh/commits?author=kvzn)
       Adrian Müller (DTT)
Adrian Müller (DTT) (https://www.telekom.de)
💻 (https://github.com/Eugeny/russh/commits?author=amtelekom)
       Simone Margaritelli
Simone Margaritelli (https://www.evilsocket.net)
💻 (https://github.com/Eugeny/russh/commits?author=evilsocket)
       Joe Grund
Joe Grund (http://joegrund.com)
💻 (https://github.com/Eugeny/russh/commits?author=jgrund)
       AspectUnk
AspectUnk (https://github.com/AspectUnk)
💻 (https://github.com/Eugeny/russh/commits?author=AspectUnk)

       Simão Mata
Simão Mata (https://0io.eu)
💻 (https://github.com/Eugeny/russh/commits?author=simao)
       Mariotaku
Mariotaku (https://mariotaku.org)
💻 (https://github.com/Eugeny/russh/commits?author=mariotaku)
       yorkz1994
yorkz1994 (https://github.com/yorkz1994)
💻 (https://github.com/Eugeny/russh/commits?author=yorkz1994)
       Ciprian Dorin Craciun
Ciprian Dorin Craciun (https://volution.ro/)
💻 (https://github.com/Eugeny/russh/commits?author=cipriancraciun)
       Eric Milliken
Eric Milliken (https://github.com/mllken)
💻 (https://github.com/Eugeny/russh/commits?author=mllken)
       Swelio
Swelio (https://github.com/Swelio)
💻 (https://github.com/Eugeny/russh/commits?author=Swelio)
       Joshua Benz
Joshua Benz (https://github.com/joshbenz)
💻 (https://github.com/Eugeny/russh/commits?author=joshbenz)

       Jan Holthuis
Jan Holthuis (http://homepage.ruhr-uni-bochum.de/Jan.Holthuis/)
🛡️
       mateuszkj
mateuszkj (https://github.com/mateuszkj)
💻 (https://github.com/Eugeny/russh/commits?author=mateuszkj)
       Saksham Mittal
Saksham Mittal (https://gotlou.srht.site)
💻 (https://github.com/Eugeny/russh/commits?author=gotlougit)
       Lucas Kent
Lucas Kent (http://canoncollision.com)
💻 (https://github.com/Eugeny/russh/commits?author=rukai)
       Raphael Druon
Raphael Druon (https://github.com/RDruon)
💻 (https://github.com/Eugeny/russh/commits?author=RDruon)
       Maya the bee
Maya the bee (https://github.com/Nurrl)
💻 (https://github.com/Eugeny/russh/commits?author=Nurrl)
       Milo Mirate
Milo Mirate (https://github.com/mmirate)
💻 (https://github.com/Eugeny/russh/commits?author=mmirate)

       George Hopkins
George Hopkins (https://github.com/george-hopkins)
💻 (https://github.com/Eugeny/russh/commits?author=george-hopkins)
       Åke Amcoff
Åke Amcoff (https://amcoff.net/)
💻 (https://github.com/Eugeny/russh/commits?author=akeamc)
       Brendon Ho
Brendon Ho (http://brendonho.com)
💻 (https://github.com/Eugeny/russh/commits?author=bho01)
       Samuel Ainsworth
Samuel Ainsworth (http://samlikes.pizza/)
💻 (https://github.com/Eugeny/russh/commits?author=samuela)
       Sherlock Holo
Sherlock Holo (https://github.com/Sherlock-Holo)
💻 (https://github.com/Eugeny/russh/commits?author=sherlock-holo)
       Alessandro Ricottone
Alessandro Ricottone (https://github.com/ricott1)
💻 (https://github.com/Eugeny/russh/commits?author=ricott1)
       T0b1-iOS
T0b1-iOS (https://github.com/T0b1-iOS)
💻 (https://github.com/Eugeny/russh/commits?author=T0b1-iOS)

       Shoaib Merchant
Shoaib Merchant (https://mecha.so)
💻 (https://github.com/Eugeny/russh/commits?author=shoaibmerchant)
       Michael Gleason
Michael Gleason (https://github.com/gleason-m)
💻 (https://github.com/Eugeny/russh/commits?author=gleason-m)
       Ana Gelez
Ana Gelez (https://ana.gelez.xyz)
💻 (https://github.com/Eugeny/russh/commits?author=elegaanz)
       Tom König
Tom König (https://github.com/tomknig)
💻 (https://github.com/Eugeny/russh/commits?author=tomknig)
       Pierre Barre
Pierre Barre (https://www.legaltile.com/)
💻 (https://github.com/Eugeny/russh/commits?author=Barre)
       Jean-Baptiste Skutnik
Jean-Baptiste Skutnik (http://skutnik.page)
💻 (https://github.com/Eugeny/russh/commits?author=spoutn1k)
       Adam Chappell
Adam Chappell (http://blog.packetsource.net/)
💻 (https://github.com/Eugeny/russh/commits?author=packetsource)

       Yaroslav Bolyukin
Yaroslav Bolyukin (https://github.com/CertainLach)
💻 (https://github.com/Eugeny/russh/commits?author=CertainLach)
       Julian
Julian (http://www.systemscape.de)
💻 (https://github.com/Eugeny/russh/commits?author=JuliDi)
       Thomas Rampelberg
Thomas Rampelberg (http://saunter.org)
💻 (https://github.com/Eugeny/russh/commits?author=grampelberg)
       Kaleb Elwert
Kaleb Elwert (https://belak.io)
📖 (https://github.com/Eugeny/russh/commits?author=belak)
       Gary Guo
Gary Guo (https://garyguo.net)
💻 (https://github.com/Eugeny/russh/commits?author=nbdd0121)
       irvingouj @ Devolutions
irvingouj @ Devolutions (https://github.com/irvingoujAtDevolution)
💻 (https://github.com/Eugeny/russh/commits?author=irvingoujAtDevolution)
       Toni Peter
Toni Peter (http://tonipeter.de)
💻 (https://github.com/Eugeny/russh/commits?author=Tehforsch)

       Nathaniel Bajo
Nathaniel Bajo (https://github.com/Nathy-bajo)
💻 (https://github.com/Eugeny/russh/commits?author=Nathy-bajo)
       Eric Rodrigues Pires
Eric Rodrigues Pires (https://eric.dev.br)
💻 (https://github.com/Eugeny/russh/commits?author=EpicEric)
       Jerome Gravel-Niquet
Jerome Gravel-Niquet (http://www.fly.io)
💻 (https://github.com/Eugeny/russh/commits?author=jeromegn)
       Quentin Santos
Quentin Santos (https://qsantos.fr/)
📖 (https://github.com/Eugeny/russh/commits?author=qsantos)
       André Almeida
André Almeida (https://github.com/ogedei-khan)
💻 (https://github.com/Eugeny/russh/commits?author=ogedei-khan)
       Mattias Eriksson
Mattias Eriksson (https://github.com/snaggen)
💻 (https://github.com/Eugeny/russh/commits?author=snaggen)
       Josh McKinney
Josh McKinney (http://joshka.net)
💻 (https://github.com/Eugeny/russh/commits?author=joshka)

       citorva
citorva (https://citorva.fr/)
💻 (https://github.com/Eugeny/russh/commits?author=citorva)
       Eric Seppanen
Eric Seppanen (https://github.com/eric-seppanen)
💻 (https://github.com/Eugeny/russh/commits?author=eric-seppanen)
       Eric Seppanen
Eric Seppanen (https://codeandbitters.com/)
💻 (https://github.com/Eugeny/russh/commits?author=ericseppanen)
       Patryk Wychowaniec
Patryk Wychowaniec (https://pwy.io)
💻 (https://github.com/Eugeny/russh/commits?author=Patryk27)
       @RandyMcMillan
@RandyMcMillan (https://www.randymcmillan.net)
💻 (https://github.com/Eugeny/russh/commits?author=RandyMcMillan)
       handewo
handewo (https://github.com/handewo)
💻 (https://github.com/Eugeny/russh/commits?author=handewo)
       Chris
Chris (https://github.com/ccbrown)
💻 (https://github.com/Eugeny/russh/commits?author=ccbrown)

       procr1337
procr1337 (https://github.com/procr1337)
💻 (https://github.com/Eugeny/russh/commits?author=procr1337)
       iHsin
iHsin (https://github.com/Itsusinn)
💻 (https://github.com/Eugeny/russh/commits?author=Itsusinn)
       Uli Schlachter
Uli Schlachter (https://github.com/psychon)
💻 (https://github.com/Eugeny/russh/commits?author=psychon)
       Jacob Van Brunt
Jacob Van Brunt (https://github.com/jvanbrunt)
💻 (https://github.com/Eugeny/russh/commits?author=jvanbrunt)
       lgmugnier
lgmugnier (https://github.com/lgmugnier)
💻 (https://github.com/Eugeny/russh/commits?author=lgmugnier)
       Mingwei Samuel
Mingwei Samuel (https://github.com/MingweiSamuel)
💻 (https://github.com/Eugeny/russh/commits?author=MingweiSamuel)
       Pascal Grange
Pascal Grange (https://twitter.com/pascalgrange)
💻 (https://github.com/Eugeny/russh/commits?author=pgrange)

       wyhaya
wyhaya (https://github.com/wyhaya)
💻 (https://github.com/Eugeny/russh/commits?author=wyhaya)
       Philippe Laflamme
Philippe Laflamme (https://github.com/plaflamme)
💻 (https://github.com/Eugeny/russh/commits?author=plaflamme)
       Tom
Tom (https://github.com/tom-90)
💻 (https://github.com/Eugeny/russh/commits?author=tom-90)
       vzex
vzex (http://dog-tunnel.tk)
💻 (https://github.com/Eugeny/russh/commits?author=vzex)
       Kenny Root
Kenny Root (https://the-b.org/)
💻 (https://github.com/Eugeny/russh/commits?author=kruton)
       Môshe van der Sterre
Môshe van der Sterre (https://github.com/moshevds)
💻 (https://github.com/Eugeny/russh/commits?author=moshevds)
       Lucy
Lucy (https://github.com/Lucy-dot-dot)
💻 (https://github.com/Eugeny/russh/commits?author=Lucy-dot-dot)

       Mark Bundschuh
Mark Bundschuh (http://mbund.dev)
💻 (https://github.com/Eugeny/russh/commits?author=mbund)
       tayu0110
tayu0110 (https://github.com/tayu0110)
💻 (https://github.com/Eugeny/russh/commits?author=tayu0110)
       Roger Knecht
Roger Knecht (https://cubic-vm.org)
💻 (https://github.com/Eugeny/russh/commits?author=rogkne)
       Guilherme Fontes
Guilherme Fontes (https://gui.wf)
💻 (https://github.com/Eugeny/russh/commits?author=gui-wf)
       Lyn
Lyn (https://github.com/zeroleo12345)
💻 (https://github.com/Eugeny/russh/commits?author=zeroleo12345)

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
