pub struct SshClient {
pub session: Handle<ClientHandler>,
/* private fields */
}Available on crate feature
ssh-real only.Expand description
Active SSH client with an authenticated session.
Fields§
§session: Handle<ClientHandler>Authenticated SSH session for low-level operations.
Implementations§
Source§impl SshClient
impl SshClient
Sourcepub async fn connect(cfg: ConnectionConfig) -> SshCliResult<Self>
pub async fn connect(cfg: ConnectionConfig) -> SshCliResult<Self>
Connects and authenticates. The full flow (TCP + handshake + auth) honors
the configuration timeout_ms.
§Errors
SshCliError::InvalidArgumentif the configuration is invalid.SshCliError::SshTimeoutse exceder o timeout total.SshCliError::ConnectionFailedem falhas TCP/handshake.SshCliError::AuthenticationFailedse o servidor rejeitar password/key (tente--key,--password-stdinou--key-passphrase-stdin).
Sourcepub async fn run_command(
&mut self,
command: &str,
max_chars: usize,
stdin_data: Option<Vec<u8>>,
) -> SshCliResult<ExecutionOutput>
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.
Trunca cada stream em max_chars codepoints UTF-8. Respeita o
configuration timeout_ms for the entire execution.
§Errors
SshCliError::ChannelFailedem falha ao abrir channel ou enviarexec.SshCliError::SshTimeoutse exceder o timeout.
Sourcepub async fn upload(
&mut self,
local: &Path,
remote: &Path,
) -> SshCliResult<TransferResult>
pub async fn upload( &mut self, local: &Path, remote: &Path, ) -> SshCliResult<TransferResult>
Upload de file local para remote via SCP (protocolo OpenSSH sink).
One-shot: stream in chunks (without loading the whole file into RAM).
§Errors
SshCliError::FileNotFoundif the local file does not exist.SshCliError::InvalidArgumentif the local path is not a regular file.SshCliError::ChannelFailedem falha ao abrir channel SCP / status remoto.SshCliError::SshTimeoutse exceder o timeout.
Sourcepub async fn download(
&mut self,
remote: &Path,
local: &Path,
) -> SshCliResult<TransferResult>
pub async fn download( &mut self, remote: &Path, local: &Path, ) -> SshCliResult<TransferResult>
Download de file remote para local via SCP (protocolo OpenSSH source).
Writes to {local}.ssh-cli.partial and renames atomically (SCP-022).
§Errors
SshCliError::Ioif the local file cannot be written.SshCliError::ChannelFailedem falha ao abrir channel SCP / status remoto.SshCliError::SshTimeoutse exceder o timeout.
Sourcepub async fn disconnect(&self) -> SshCliResult<()>
pub async fn disconnect(&self) -> SshCliResult<()>
Sourcepub async fn open_tunnel_channel(
&self,
remote_host: &str,
remote_port: u16,
endereco_origem: &str,
porta_origem: u16,
) -> SshCliResult<Box<dyn TunnelChannel>>
pub async fn open_tunnel_channel( &self, remote_host: &str, remote_port: u16, endereco_origem: &str, porta_origem: u16, ) -> SshCliResult<Box<dyn TunnelChannel>>
Abre channel direct-tcpip para forwarding SSH.
Trait Implementations§
Source§impl SshClientTrait for SshClient
impl SshClientTrait for SshClient
Source§fn connect<'async_trait>(
cfg: ConnectionConfig,
) -> Pin<Box<dyn Future<Output = Result<Box<Self>, SshCliError>> + Send + 'async_trait>>where
Self: 'async_trait,
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.
Source§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,
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
Source§fn upload<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut 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,
fn upload<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut 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,
Faz upload de um file local para o servidor remoto via SCP.
Source§fn download<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut 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,
fn download<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut 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,
Faz download de um file remoto para o sistema local via SCP.
Source§fn open_tunnel_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
remote_host: &'life1 str,
remote_port: u16,
endereco_origem: &'life2 str,
porta_origem: 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,
fn open_tunnel_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
remote_host: &'life1 str,
remote_port: u16,
endereco_origem: &'life2 str,
porta_origem: 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,
Abre um channel
direct-tcpip para forwarding de tunnel.Source§fn disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), SshCliError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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§
impl !RefUnwindSafe for SshClient
impl !UnwindSafe for SshClient
impl Freeze for SshClient
impl Send for SshClient
impl Sync for SshClient
impl Unpin for SshClient
impl UnsafeUnpin for SshClient
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