#ssh #thrussh #tokio

t-ssh-client

Rust异步ssh客户端,由thrussh封装

5个版本

0.2.1 2022年7月26日
0.2.0 2022年7月25日
0.1.3 2022年7月25日

#3 in #thrussh

MIT许可证

15KB
186

t-ssh-client

Rust异步ssh客户端thrussh封装。

Crates.io Apache-2.0 licensed API docs

用法

# 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(())
}

许可证

本项目采用Apache-2.0许可证

依赖项

~21–34MB
~287K SLoC