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//!     // if you want to use SSH agent (Unix/Linux only), then use following:
24//!     // AuthMethod::with_agent();
25//!     let auth_method = AuthMethod::with_password("root");
26//!     let mut client = Client::connect(
27//!         ("10.10.10.2", 22),
28//!         "root",
29//!         auth_method,
30//!         ServerCheckMethod::NoCheck,
31//!     ).await?;
32//!
33//!     let result = client.execute("echo Hello SSH").await?;
34//!     assert_eq!(result.stdout, "Hello SSH\n");
35//!     assert_eq!(result.exit_status, 0);
36//!
37//!     let result = client.execute("echo Hello Again :)").await?;
38//!     assert_eq!(result.stdout, "Hello Again :)\n");
39//!     assert_eq!(result.exit_status, 0);
40//!
41//!     Ok(())
42//! }
43//! ```
44
45pub mod client;
46pub mod error;
47mod to_socket_addrs_with_hostname;
48
49pub use client::{AuthMethod, Client, ServerCheckMethod};
50pub use error::Error;
51pub use to_socket_addrs_with_hostname::ToSocketAddrsWithHostname;
52
53pub use russh::client::Config;