Crates.io | t-ssh-client |
lib.rs | t-ssh-client |
version | 0.2.1 |
source | src |
created_at | 2022-07-06 13:25:19.134603 |
updated_at | 2022-07-26 03:49:48.079944 |
description | Rust async ssh client wrapped by thrussh |
homepage | https://github.com/kolapapa/t-ssh-client |
repository | https://github.com/kolapapa/t-ssh-client |
max_upload_size | |
id | 620464 |
size | 48,621 |
Rust async ssh client
wrapped by thrussh.
# enable openssl support
t-ssh-client = { version = "0.2.1", features = ["openssl"]}
use std::env;
use std::time::Duration;
use t_ssh_client::{AuthMethod, Client};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let password = env::var("PASSWORD")?;
let mut client = Client::builder()
.username("admin")
.auth(AuthMethod::Password(password))
.connect_timeout(Duration::from_secs(2))
.connect("192.168.62.1:22")
.await?;
println!("login success");
let output = client.output("echo 'hello, world!'").await?;
assert_eq!(output.stdout_string(), "hello, world!\n");
Ok(())
}
This project is licensed under the Apache-2.0 license.