1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Dependencies
//! ```toml
//! ssh-rs = "0.4.2"
//! ```
//!
//!Rust implementation of ssh2.0 client.
//!
//! Basic usage
//! ```no_run
//! use ssh;
//!
//! let mut session = ssh::create_session()
//!     .username("ubuntu")
//!     .password("password")
//!     .private_key_path("./id_rsa")
//!     .connect("127.0.0.1:22")
//!     .unwrap()
//!     .run_local();
//! let exec = session.open_exec().unwrap();
//! let vec: Vec<u8> = exec.send_command("ls -all").unwrap();
//! println!("{}", String::from_utf8(vec).unwrap());
//! // Close session.
//! session.close();
//! ```
//! For more usage examples and details, please see the
//! [Readme](https://github.com/1148118271/ssh-rs) &
//! [Examples](https://github.com/1148118271/ssh-rs/tree/main/examples)
//! in our [git repo](https://github.com/1148118271/ssh-rs)
//!

pub mod algorithm;
mod channel;
mod client;
mod config;
mod constant;
mod model;
mod session;
mod util;

pub mod error;

pub use channel::*;
pub use error::SshError;
pub use error::SshResult;
pub use model::{TerminalSize, TerminalSizeType};
pub use session::{LocalSession, SessionBroker, SessionBuilder, SessionConnector};

/// create a session via session builder w/ default configuration
///
pub fn create_session() -> SessionBuilder {
    SessionBuilder::new()
}

/// create a session via session builder w/o default configuration
///
pub fn create_session_without_default() -> SessionBuilder {
    SessionBuilder::disable_default()
}