pub struct SessionBuilder<'sb> { /* private fields */ }Expand description
Builder for configuring and creating an SSH Session.
Use Session::init to create a new builder, then chain
configuration methods, and finally call SessionBuilder::build
to create the session.
§Example
use simple_ssh::Session;
let session = Session::init()
.with_host("example.com")
.with_user("admin")
.with_port(2222)
.with_passwd("secret")
.build()
.expect("Failed to build session");Implementations§
Source§impl<'sb> SessionBuilder<'sb>
impl<'sb> SessionBuilder<'sb>
Sourcepub fn with_cert_opt(self, cert: Option<PathBuf>) -> Self
pub fn with_cert_opt(self, cert: Option<PathBuf>) -> Self
Sourcepub fn with_key_opt(self, key: Option<PathBuf>) -> Self
pub fn with_key_opt(self, key: Option<PathBuf>) -> Self
Sourcepub fn with_key(self, key: PathBuf) -> Self
pub fn with_key(self, key: PathBuf) -> Self
Sets the SSH private key path for authentication.
When a key is provided, public key authentication is used.
§Arguments
key- Path to the private key file
Sourcepub fn with_cmd(self, cmdv: Vec<String>) -> Self
pub fn with_cmd(self, cmdv: Vec<String>) -> Self
Sets the command to execute for interactive sessions.
§Arguments
cmdv- Command and its arguments as a vector
Sourcepub fn with_passwd(self, passwd: &str) -> Self
pub fn with_passwd(self, passwd: &str) -> Self
Sets the password for authentication.
When a password is provided (and no key), password authentication is used.
§Arguments
passwd- Password string
Sourcepub fn with_passwd_opt(self, passwd: Option<String>) -> Self
pub fn with_passwd_opt(self, passwd: Option<String>) -> Self
Sourcepub fn with_scope(self, scope: &str) -> Self
pub fn with_scope(self, scope: &str) -> Self
Sets the IPv6 scope ID (interface name or number).
Required for link-local IPv6 addresses.
§Arguments
scope- Interface name (e.g., “eth0”) or numeric scope ID
Sourcepub fn with_inactivity_timeout(self, timeout: Option<Duration>) -> Self
pub fn with_inactivity_timeout(self, timeout: Option<Duration>) -> Self
Sets the inactivity timeout for the SSH connection.
Set to None to disable the timeout.
§Arguments
timeout- Optional duration for inactivity timeout
Auto Trait Implementations§
impl<'sb> Freeze for SessionBuilder<'sb>
impl<'sb> RefUnwindSafe for SessionBuilder<'sb>
impl<'sb> Send for SessionBuilder<'sb>
impl<'sb> Sync for SessionBuilder<'sb>
impl<'sb> Unpin for SessionBuilder<'sb>
impl<'sb> UnwindSafe for SessionBuilder<'sb>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more