async_ssh2_tokio/
lib.rs

1//! This library is an asynchronous and easy-to-use high level ssh client library
2//! for rust with the tokio runtime. Powered by the rust ssh implementation
3//! [russh](https://github.com/warp-tech/russh), a fork of thrussh.
4//!
5//! The heart of this library is [`client::Client`]. Use this for connection, authentification and execution.
6//!
7//! # Features
8//! * Connect to a SSH Host via IP
9//! * Execute commands on the remote host
10//! * Get the stdout and exit code of the command
11//!
12//! # Example
13//! ```no_run
14//! use async_ssh2_tokio::client::{Client, AuthMethod, ServerCheckMethod};
15//! #[tokio::main]
16//! async fn main() -> Result<(), async_ssh2_tokio::Error> {
17//!     // if you want to use key auth, then use following:
18//!     // AuthMethod::with_key_file("key_file_name", Some("passphrase"));
19//!     // or
20//!     // AuthMethod::with_key_file("key_file_name", None);
21//!     // or
22//!     // AuthMethod::with_key(key: &str, passphrase: Option<&str>)
23//!     let auth_method = AuthMethod::with_password("root");
24//!     let mut client = Client::connect(
25//!         ("10.10.10.2", 22),
26//!         "root",
27//!         auth_method,
28//!         ServerCheckMethod::NoCheck,
29//!     ).await?;
30//!
31//!     let result = client.execute("echo Hello SSH").await?;
32//!     assert_eq!(result.stdout, "Hello SSH\n");
33//!     assert_eq!(result.exit_status, 0);
34//!
35//!     let result = client.execute("echo Hello Again :)").await?;
36//!     assert_eq!(result.stdout, "Hello Again :)\n");
37//!     assert_eq!(result.exit_status, 0);
38//!
39//!     Ok(())
40//! }
41//! ```
42
43pub mod client;
44pub mod error;
45mod to_socket_addrs_with_hostname;
46
47pub use client::{AuthMethod, Client, ServerCheckMethod};
48pub use error::Error;
49pub use to_socket_addrs_with_hostname::ToSocketAddrsWithHostname;
50
51pub use russh::client::Config;