async-ssh2-russh
An asynchronous SSH client wrapper around russh.
Features
Thin wrapper around russh, providing a few additional features:
- Asynchronous reading from stdoutandstderrseparately.
- Asynchronous writing to stdin.
- Asynchronous event handling for exit status codes, EOF, closing, etc.
- [AsyncSession::open_sftp] for SFTP support viarussh-sftp(requires thesftpfeature).
Usage
Add the following to your Cargo.toml:
[]
 = "..."
This crate provides two main types, [AsyncSession] and [AsyncChannel]. A session represents a connection to an SSH
server, while a channel represents a single communication thread within that session, for example for executing a
command, or opening an SFTP session, etc. These two structs are thin wrappers around [russh::client::Handler] and
[russh::ChannelWriteHalf], respectively, with additional methods for asynchronous stream and event handling. They each
implement [Deref] for their underlying types, so you can use them as if they were the original types.
Example
# let _ = async ;
Comparisons
- Why not use russhdirectly?russhdoes not provide easy ways to read fromstdoutandstderrseparately, or to wait for specific events like exit status codes or EOF. Perhaps this functionality will be subsumed byrusshin the future and make this crate obsolete.
- Why not async-ssh2-tokio?async-ssh2-tokiois also a wrapper aroundrussh, but only provides a monolithicexecutemethod which prevents asynchronous/dynamic interaction with the command'sstdout,stderr, andstdin.
- Why not async-ssh2-lite?async-ssh2-liteis a wrapper around thelibssh2C library, causing additional build complexity and compile time. Howeverasync-ssh2-lite's APIs are very similar to this crate's, and likely more complete.