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: StringRemote hostname or IP address
port: u16SSH port (default: 22)
username: StringUsername 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: u64Keepalive interval in seconds (default: 30s) Sends keepalive packets to maintain connection like a human user
keepalive_max: u64Maximum 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: u64Number of reconnect retries after the initial attempt (default: 3)
reconnect_backoff_ms: u64Base reconnect backoff in milliseconds (default: 250)
health_probe_timeout_ms: u64Health probe timeout in milliseconds for active session checks (default: 1500)
host_key_checking: HostKeyCheckModeSSH host key verification policy.
known_hosts: Option<PathBuf>Optional known_hosts file path.
Implementations§
Source§impl SshConfig
impl SshConfig
Sourcepub fn new(host: impl Into<String>, username: impl Into<String>) -> Self
pub fn new(host: impl Into<String>, username: impl Into<String>) -> Self
Create a new SSH configuration with minimal required fields
Sourcepub fn with_password(self, password: impl Into<String>) -> Self
pub fn with_password(self, password: impl Into<String>) -> Self
Set password authentication
Sourcepub fn with_private_key(self, key: impl Into<String>) -> Self
pub fn with_private_key(self, key: impl Into<String>) -> Self
Set private key authentication (key content, not path)
Sourcepub fn with_su_password(self, password: impl Into<String>) -> Self
pub fn with_su_password(self, password: impl Into<String>) -> Self
Set su password for privilege elevation
Sourcepub fn with_sudo_password(self, password: impl Into<String>) -> Self
pub fn with_sudo_password(self, password: impl Into<String>) -> Self
Set sudo password for sudo commands
Sourcepub fn with_keepalive_interval(self, secs: u64) -> Self
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)
Sourcepub fn with_keepalive_max(self, max: u64) -> Self
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
Sourcepub fn with_max_output_tokens(self, tokens: Option<usize>) -> Self
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)
Sourcepub fn with_reconnect_retries(self, retries: u64) -> Self
pub fn with_reconnect_retries(self, retries: u64) -> Self
Set reconnect retries after the initial attempt (default: 3)
Sourcepub fn with_reconnect_backoff_ms(self, backoff_ms: u64) -> Self
pub fn with_reconnect_backoff_ms(self, backoff_ms: u64) -> Self
Set base reconnect backoff in milliseconds (default: 250)
Sourcepub fn with_health_probe_timeout_ms(self, timeout_ms: u64) -> Self
pub fn with_health_probe_timeout_ms(self, timeout_ms: u64) -> Self
Set health probe timeout in milliseconds (default: 1500)
Sourcepub fn with_host_key_checking(self, mode: HostKeyCheckMode) -> Self
pub fn with_host_key_checking(self, mode: HostKeyCheckMode) -> Self
Set SSH host key verification policy.
Sourcepub fn with_known_hosts(self, known_hosts: Option<PathBuf>) -> Self
pub fn with_known_hosts(self, known_hosts: Option<PathBuf>) -> Self
Set a custom known_hosts file path.