pub struct SshSession {
pub host: HostSpec,
pub env: SshEnv,
pub config_file: Option<PathBuf>,
}Expand description
SSH destination plus askpass policy.
Fields§
§host: HostSpecOpenSSH Host or user@host.
env: SshEnvAskpass / env policy.
config_file: Option<PathBuf>Optional ssh -F / scp -F config file (tests / non-default layouts).
Implementations§
Source§impl SshSession
impl SshSession
fn with_config_prefix(&self, rest: &[&str]) -> Vec<String>
True when BatchMode SSH with this identity already succeeds (key is on the box).
Sourcepub fn exec(
&self,
runner: &dyn ProcessRunner,
remote_cmd: &str,
stdio: StdioMode,
) -> Result<CommandOutput>
pub fn exec( &self, runner: &dyn ProcessRunner, remote_cmd: &str, stdio: StdioMode, ) -> Result<CommandOutput>
Run a remote shell command via ssh.
Probes use StdioMode::Capture (no TTY). Interactive apply uses
StdioMode::Inherit with ssh -tt so remote sudo can prompt.
§Errors
Returns crate::HortoError::CommandFailed when ssh exits non-zero.
Sourcepub fn exec_stdin(
&self,
runner: &dyn ProcessRunner,
remote_cmd: &str,
stdin: &[u8],
) -> Result<CommandOutput>
pub fn exec_stdin( &self, runner: &dyn ProcessRunner, remote_cmd: &str, stdin: &[u8], ) -> Result<CommandOutput>
Run a remote command with bytes on SSH stdin (no remote TTY).
§Errors
Returns crate::HortoError::CommandFailed when ssh exits non-zero.
Sourcepub fn exec_stdin_reboot(
&self,
runner: &dyn ProcessRunner,
remote_cmd: &str,
stdin: &[u8],
) -> Result<CommandOutput>
pub fn exec_stdin_reboot( &self, runner: &dyn ProcessRunner, remote_cmd: &str, stdin: &[u8], ) -> Result<CommandOutput>
Like Self::exec_stdin, with short SSH keepalives (box reboot / host drop).
§Errors
Returns crate::HortoError::CommandFailed when ssh exits non-zero.
fn exec_stdin_inner( &self, runner: &dyn ProcessRunner, remote_cmd: &str, stdin: &[u8], reboot_timeouts: bool, ) -> Result<CommandOutput>
Sourcepub fn scp_to(
&self,
runner: &dyn ProcessRunner,
local: &Path,
remote_path: &str,
) -> Result<()>
pub fn scp_to( &self, runner: &dyn ProcessRunner, local: &Path, remote_path: &str, ) -> Result<()>
Copy a local file to a remote path with scp.
§Errors
Returns crate::HortoError when paths are invalid or scp fails.
Sourcepub fn install_ssh_key(&self, runner: &dyn ProcessRunner) -> Result<()>
pub fn install_ssh_key(&self, runner: &dyn ProcessRunner) -> Result<()>
Opt-in: install the default identity pubkey on the box via ssh-copy-id -i.
Skips ssh-copy-id when BatchMode SSH with that identity already works
(key already authorized). Without -i, ssh-copy-id would install every
agent key; we always pass a single .pub.
§Errors
Returns crate::HortoError when no default pubkey exists or ssh-copy-id fails.
Sourcepub fn remote_has_rsync(&self, runner: &dyn ProcessRunner) -> bool
pub fn remote_has_rsync(&self, runner: &dyn ProcessRunner) -> bool
Probe whether rsync exists on the remote host.
Trait Implementations§
Source§impl Clone for SshSession
impl Clone for SshSession
Source§fn clone(&self) -> SshSession
fn clone(&self) -> SshSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more