Struct Session

Source
pub struct Session { /* private fields */ }
Expand description

See Session.

Implementations§

Source§

impl Session

Source

pub fn new() -> Result<Session, Error>

See new.

Source

pub async fn set_banner(&self, banner: &str) -> Result<(), Error>

Source

pub fn set_allow_sigpipe(&self, block: bool)

Source

pub fn set_compress(&self, compress: bool)

Source

pub fn is_blocking(&self) -> bool

Source

pub fn set_timeout(&self, timeout_ms: u32)

Source

pub fn timeout(&self) -> u32

See timeout.

Source

pub async fn handshake(&mut self) -> Result<(), Error>

See handshake.

Source

pub fn set_tcp_stream(&mut self, stream: Async<TcpStream>) -> Result<(), Error>

Sets the tcp stream for the underlying ssh2 lib.

use async_ssh2::Session;
use std::net::TcpStream;
use smol::Async;

#[tokio::main]
async fn main() {
    let stream = Async::<TcpStream>::connect("127.0.0.1:22").await.unwrap();
    let mut sess = async_ssh2::Session::new().unwrap();
    sess.set_tcp_stream(stream).unwrap();
}
Source

pub async fn userauth_password( &self, username: &str, password: &str, ) -> Result<(), Error>

Source

pub fn userauth_keyboard_interactive<P: KeyboardInteractivePrompt>( &self, _username: &str, _prompter: &mut P, ) -> Result<(), Error>

Source

pub async fn userauth_agent(&self, username: &str) -> Result<(), Error>

Source

pub async fn userauth_pubkey_file( &self, username: &str, pubkey: Option<&Path>, privatekey: &Path, passphrase: Option<&str>, ) -> Result<(), Error>

Source

pub async fn userauth_pubkey_memory( &self, username: &str, pubkeydata: Option<&str>, privatekeydata: &str, passphrase: Option<&str>, ) -> Result<(), Error>

Source

pub async fn userauth_hostbased_file( &self, username: &str, publickey: &Path, privatekey: &Path, passphrase: Option<&str>, hostname: &str, local_username: Option<&str>, ) -> Result<(), Error>

Source

pub fn authenticated(&self) -> bool

Source

pub async fn auth_methods(&self, username: &str) -> Result<&str, Error>

Source

pub fn method_pref( &self, method_type: MethodType, prefs: &str, ) -> Result<(), Error>

Source

pub fn methods(&self, method_type: MethodType) -> Option<&str>

See methods.

Source

pub fn supported_algs( &self, method_type: MethodType, ) -> Result<Vec<&'static str>, Error>

Source

pub fn agent(&self) -> Result<Agent, Error>

See agent.

Source

pub fn known_hosts(&self) -> Result<KnownHosts, Error>

Source

pub async fn channel_session(&self) -> Result<Channel, Error>

Source

pub async fn channel_direct_tcpip( &self, host: &str, port: u16, src: Option<(&str, u16)>, ) -> Result<Channel, Error>

Source

pub async fn channel_forward_listen( &self, remote_port: u16, host: Option<&str>, queue_maxsize: Option<u32>, ) -> Result<(Listener, u16), Error>

Source

pub async fn scp_recv( &self, path: &Path, ) -> Result<(Channel, ScpFileStat), Error>

See scp_recv.

Source

pub async fn scp_send( &self, remote_path: &Path, mode: i32, size: u64, times: Option<(u64, u64)>, ) -> Result<Channel, Error>

See scp_send.

Source

pub async fn sftp(&self) -> Result<Sftp, Error>

See sftp.

Source

pub async fn channel_open( &self, channel_type: &str, window_size: u32, packet_size: u32, message: Option<&str>, ) -> Result<Channel, Error>

Source

pub fn banner(&self) -> Option<&str>

See banner.

Source

pub fn banner_bytes(&self) -> Option<&[u8]>

Source

pub fn host_key(&self) -> Option<(&[u8], HostKeyType)>

See host_key.

Source

pub fn host_key_hash(&self, hash: HashType) -> Option<&[u8]>

Source

pub fn set_keepalive(&self, want_reply: bool, interval: u32)

Source

pub async fn keepalive_send(&self) -> Result<u32, Error>

Source

pub async fn disconnect( &self, reason: Option<DisconnectCode>, description: &str, lang: Option<&str>, ) -> Result<(), Error>

Trait Implementations§

Source§

impl AsRawFd for Session

Source§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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