Skip to main content

SshClient

Struct SshClient 

Source
pub struct SshClient {
    pub session: Handle<ClientHandler>,
    /* private fields */
}
Available on crate feature ssh-real only.
Expand description

Real SSH client backed by russh (default feature ssh-real). Active SSH client with an authenticated session.

Fields§

§session: Handle<ClientHandler>

Authenticated SSH session for low-level operations.

Implementations§

Source§

impl SshClient

Source

pub fn timeout_ms(&self) -> u64

Wall-clock timeout (ms) from connection config (CLI/XDG) — G-SFTP-R05.

Source§

impl SshClient

Source

pub async fn connect(cfg: ConnectionConfig) -> SshCliResult<Self>

Connects and authenticates. The full flow (TCP + handshake + auth) honors the configuration timeout_ms.

§Errors
Source

pub async fn run_command( &mut self, command: &str, max_chars: usize, stdin_data: Option<Vec<u8>>, ) -> SshCliResult<ExecutionOutput>

Runs a remote shell command and captures stdout/stderr in parallel.

§

impl SshClient

pub async fn upload( &self, local: &Path, remote: &Path, ) -> SshCliResult<TransferResult>

Uploads a local file to the remote host via SCP (OpenSSH sink protocol).

One-shot: stream in chunks (without loading the whole file into RAM).

§Errors

pub async fn download( &self, remote: &Path, local: &Path, ) -> SshCliResult<TransferResult>

Downloads a remote file to the local path via SCP (OpenSSH source protocol).

Writes to {local}.ssh-cli.partial and renames atomically (SCP-022).

§Errors
§

impl SshClient

pub async fn disconnect(&self) -> SshCliResult<()>

Cleanly closes the SSH session.

§Errors

Propagates transport errors returned by disconnect.

pub async fn open_tunnel_channel( &self, remote_host: &str, remote_port: u16, origin_addr: &str, origin_port: u16, ) -> SshCliResult<Box<dyn TunnelChannel>>

Opens a direct-tcpip channel for SSH forwarding.

pub async fn open_sftp(&self) -> SshCliResult<SftpSession>

Opens one SFTP subsystem session (reuse for multi-file / multi-op).

pub async fn sftp_upload( &self, local: &Path, remote: &str, ) -> SshCliResult<TransferResult>

One-shot SFTP upload of a regular file (opens+closes subsystem).

pub async fn sftp_download( &self, remote: &str, local: &Path, ) -> SshCliResult<TransferResult>

One-shot SFTP download of a regular file.

pub async fn sftp_upload_tree( &self, local_dir: &Path, remote_dir: &str, ) -> SshCliResult<TransferResult>

One-shot recursive SFTP upload tree.

pub async fn sftp_download_tree( &self, remote_dir: &str, local_dir: &Path, ) -> SshCliResult<TransferResult>

One-shot recursive SFTP download tree.

Trait Implementations§

Source§

impl Debug for SshClient

Source§

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

Formats the value using the given formatter. Read more
§

impl SshClientTrait for SshClient

§

fn connect<'async_trait>( cfg: ConnectionConfig, ) -> Pin<Box<dyn Future<Output = Result<Box<Self>, SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait,

Connects to an SSH server and authenticates with the provided credentials.
§

fn run_command<'life0, 'life1, 'async_trait>( &'life0 mut self, cmd: &'life1 str, max_chars: usize, stdin_data: Option<Vec<u8>>, ) -> Pin<Box<dyn Future<Output = Result<ExecutionOutput, SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Runs a remote shell command and returns the captured output. Read more
§

fn upload<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, local: &'life1 Path, remote: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<TransferResult, SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Uploads a local file to the remote server via SCP.
§

fn download<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, remote: &'life1 Path, local: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<TransferResult, SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Downloads a remote file to the local filesystem via SCP.
§

fn open_tunnel_channel<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, remote_host: &'life1 str, remote_port: u16, origin_addr: &'life2 str, origin_port: u16, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn TunnelChannel>, SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Opens a direct-tcpip channel for tunnel forwarding.
§

fn disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Cleanly closes the SSH connection.

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> 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, 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