| Crates.io | async-ssh2-tokio |
| lib.rs | async-ssh2-tokio |
| version | 0.9.1 |
| created_at | 2021-11-30 01:23:26.434534+00 |
| updated_at | 2025-08-10 01:27:51.461734+00 |
| description | Asynchronous and easy-to-use high level ssh client library for rust. |
| homepage | |
| repository | https://github.com/Miyoshi-Ryota/async-ssh2-tokio |
| max_upload_size | |
| id | 489558 |
| size | 127,627 |
This library is an asynchronous and easy-to-use high level SSH client library for rust with the tokio runtime. Powered by the rust SSH implementation russh.
[dependencies]
tokio = "1"
async-ssh2-tokio = "0.9.1"
use async_ssh2_tokio::client::{Client, AuthMethod, ServerCheckMethod};
#[tokio::main]
async fn main() -> Result<(), async_ssh2_tokio::Error> {
// if you want to use key auth, then use following:
// AuthMethod::with_key_file("key_file_name", Some("passphrase"));
// or
// AuthMethod::with_key_file("key_file_name", None);
// or
// AuthMethod::with_key(key: &str, passphrase: Option<&str>)
// if you want to use SSH agent (Unix/Linux only), then use following:
// AuthMethod::with_agent();
let auth_method = AuthMethod::with_password("root");
let mut client = Client::connect(
("10.10.10.2", 22),
"root",
auth_method,
ServerCheckMethod::NoCheck,
).await?;
let result = client.execute("echo Hello SSH").await?;
assert_eq!(result.stdout, "Hello SSH\n");
assert_eq!(result.exit_status, 0);
let result = client.execute("echo Hello Again :)").await?;
assert_eq!(result.stdout, "Hello Again :)\n");
assert_eq!(result.exit_status, 0);
Ok(())
}
./tests/run_unit_tests.sh