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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
//! Dependencies
//! ```toml
//! ssh-rs = "0.3.2"
//! ```
//!
//!Rust implementation of ssh2.0 client.
//!
//! Basic usage
//! ```no_run
//! use ssh_rs::ssh;
//!
//! ssh::debug();
//!
//! 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 slog;
mod util;
pub mod error;
pub use channel::*;
pub(crate) use error::SshError;
pub use error::{SshErrorKind, SshResult};
pub use session::{LocalSession, SessionBroker, SessionBuilder, SessionConnector};
pub mod ssh {
use crate::{session::SessionBuilder, slog::Slog};
/// 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()
}
/// set the global log level to `INFO`
///
pub fn enable_log() {
Slog::default()
}
/// set the global log level to `TRACE`
///
/// for diagnostic purposes only
pub fn debug() {
Slog::debug()
}
}