https://github.com/pbar1/ssh2-async-rs
Performant and runtime-agnostic async wrapper for ssh2-rs
https://github.com/pbar1/ssh2-async-rs
async libssh2 rust ssh
Last synced: 17 days ago
JSON representation
Performant and runtime-agnostic async wrapper for ssh2-rs
- Host: GitHub
- URL: https://github.com/pbar1/ssh2-async-rs
- Owner: pbar1
- License: apache-2.0
- Created: 2026-01-06T05:37:39.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-05-07T17:19:41.000Z (about 1 month ago)
- Last Synced: 2026-05-07T19:21:35.932Z (about 1 month ago)
- Topics: async, libssh2, rust, ssh
- Language: Rust
- Homepage:
- Size: 41 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# ssh2-async
Runtime-agnostic async wrappers for [`ssh2`][ssh2].
Includes pluggable runtime support through the `RuntimeContext` trait to
intelligently support async without resorting to busy-waiting. [Tokio][tokio]
support is implemented already and enabled by default.
Also implements `futures::io::{AsyncRead, AsyncWrite}` for things that
implement `std::io::{Read, Write}` in `ssh2`, such as channels and files.
## Example
```rust
use futures::AsyncReadExt;
use ssh2_async::{Session, TokioContext};
use tokio::net::TcpStream;
#[tokio::main]
async fn main() -> Result<(), ssh2::Error> {
let tcp = TcpStream::connect("127.0.0.1:22")
.await
.unwrap()
.into_std()
.unwrap();
let mut session = Session::::from_stream(tcp)?;
session.handshake().await?;
session.userauth_password("user", "password").await?;
let mut channel = session.channel_session().await?;
channel.exec("uname -a").await?;
let mut output = String::new();
channel.read_to_string(&mut output).await.unwrap();
channel.wait_close().await?;
println!("{output}");
Ok(())
}
```
[ssh2]: https://github.com/alexcrichton/ssh2-rs
[tokio]: https://tokio.rs/