pub struct Session<S: AsyncRead + AsyncWrite>(_);
Expand description
An established and authenticated SSH session.
You can use this session to execute commands on the remote host using Session::open_exec
.
This will give you back a [Channel
], which can be used to read from the resulting process’
STDOUT
, or to write the the process’ STDIN
.
Implementations§
source§impl<S: AsyncRead + AsyncWrite + Tcp + 'static> Session<S>
impl<S: AsyncRead + AsyncWrite + Tcp + 'static> Session<S>
sourcepub fn new(stream: S, handle: &Handle) -> Result<NewSession<S>, HandlerError<()>>
pub fn new(stream: S, handle: &Handle) -> Result<NewSession<S>, HandlerError<()>>
Establish a new SSH session on top of the given stream.
The resulting SSH session is initially unauthenticated (see NewSession
), and must be
authenticated before it becomes useful.
Note that the reactor behind the given handle
must continue to be driven for any
channels created from this Session
to work.
sourcepub fn last_error(&mut self) -> Option<HandlerError<()>>
pub fn last_error(&mut self) -> Option<HandlerError<()>>
Retrieve the last error encountered during this session.
Note that it is unlikely you will be able to use any items associated with this session once it has returned an error.
Calling this method clears the error.
sourcepub fn open_exec<'a>(&mut self, cmd: &'a str) -> ChannelOpenFuture<'a, S>
pub fn open_exec<'a>(&mut self, cmd: &'a str) -> ChannelOpenFuture<'a, S>
Establish a new channel over this session to execute the given command.
Note that any errors encountered while operating on the channel after it has been opened
will manifest only as reads or writes no longer succeeding. To get the underlying error,
call Session::last_error
.