Skip to main content

SshConfig

Struct SshConfig 

Source
pub struct SshConfig {
Show 15 fields pub host: String, pub port: u16, pub username: String, pub password: Option<String>, pub private_key: Option<String>, pub su_password: Option<String>, pub sudo_password: Option<String>, pub keepalive_interval: u64, pub keepalive_max: u64, pub max_output_tokens: Option<usize>, pub reconnect_retries: u64, pub reconnect_backoff_ms: u64, pub health_probe_timeout_ms: u64, pub host_key_checking: HostKeyCheckMode, pub known_hosts: Option<PathBuf>,
}
Expand description

SSH connection configuration

Fields§

§host: String

Remote hostname or IP address

§port: u16

SSH port (default: 22)

§username: String

Username for authentication

§password: Option<String>

Password for password authentication

§private_key: Option<String>

Private key content (not path!) for key authentication

§su_password: Option<String>

Password for su elevation to root

§sudo_password: Option<String>

Password for sudo commands (if different from su_password)

§keepalive_interval: u64

Keepalive interval in seconds (default: 30s) Sends keepalive packets to maintain connection like a human user

§keepalive_max: u64

Maximum keepalive failures before disconnecting (default: 3) How many keepalive packets can be missed before connection drops

§max_output_tokens: Option<usize>

Maximum output tokens for command execution (default: 16_000) Prevents OOM and context overflow for large outputs

§reconnect_retries: u64

Number of reconnect retries after the initial attempt (default: 3)

§reconnect_backoff_ms: u64

Base reconnect backoff in milliseconds (default: 250)

§health_probe_timeout_ms: u64

Health probe timeout in milliseconds for active session checks (default: 1500)

§host_key_checking: HostKeyCheckMode

SSH host key verification policy.

§known_hosts: Option<PathBuf>

Optional known_hosts file path.

Implementations§

Source§

impl SshConfig

Source

pub fn new(host: impl Into<String>, username: impl Into<String>) -> Self

Create a new SSH configuration with minimal required fields

Source

pub fn with_port(self, port: u16) -> Self

Set the SSH port

Source

pub fn with_password(self, password: impl Into<String>) -> Self

Set password authentication

Source

pub fn with_private_key(self, key: impl Into<String>) -> Self

Set private key authentication (key content, not path)

Source

pub fn with_su_password(self, password: impl Into<String>) -> Self

Set su password for privilege elevation

Source

pub fn with_sudo_password(self, password: impl Into<String>) -> Self

Set sudo password for sudo commands

Source

pub fn with_keepalive_interval(self, secs: u64) -> Self

Set keepalive interval in seconds (default: 30s) Lower values = more frequent keepalives (detect dead connections faster) Higher values = less network overhead (more like idle human session)

Source

pub fn with_keepalive_max(self, max: u64) -> Self

Set maximum keepalive failures before disconnecting (default: 3) Total idle timeout = keepalive_interval * keepalive_max Example: 30s * 3 = 90s of inactivity before disconnect

Source

pub fn with_max_output_tokens(self, tokens: Option<usize>) -> Self

Set maximum output tokens for command execution (default: 16_000) Set to None for unlimited output (not recommended for large outputs)

Source

pub fn with_reconnect_retries(self, retries: u64) -> Self

Set reconnect retries after the initial attempt (default: 3)

Source

pub fn with_reconnect_backoff_ms(self, backoff_ms: u64) -> Self

Set base reconnect backoff in milliseconds (default: 250)

Source

pub fn with_health_probe_timeout_ms(self, timeout_ms: u64) -> Self

Set health probe timeout in milliseconds (default: 1500)

Source

pub fn with_host_key_checking(self, mode: HostKeyCheckMode) -> Self

Set SSH host key verification policy.

Source

pub fn with_known_hosts(self, known_hosts: Option<PathBuf>) -> Self

Set a custom known_hosts file path.

Trait Implementations§

Source§

impl Clone for SshConfig

Source§

fn clone(&self) -> SshConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SshConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more