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