[−][src]Struct openssh::Session
A single SSH session to a remote host.
You can use [command
] to start a new command on the connected machine.
When the Session
is dropped, the connection to the remote host is severed, and any errors
silently ignored. To disconnect and be alerted to errors, use [close
].
Methods
impl Session
[src]
pub fn connect(destination: &str, check: KnownHosts) -> Result<Self, Error>
[src]
Connect to the host at the given addr
over SSH.
The format of destination
is the same as the destination
argument to ssh
. It may be
specified as either [user@]hostname
or a URI of the form ssh://[user@]hostname[:port]
.
If connecting requires interactive authentication based on STDIN
(such as reading a
password), the connection will fail. Consider setting up keypair-based authentication
instead.
pub fn check(&self) -> Result<(), Error>
[src]
Check the status of the underlying SSH connection.
Since this does not run a remote command, it has a better chance of extracting useful error messages than other commands.
pub fn command<S: AsRef<OsStr>>(&self, program: S) -> Command
[src]
Constructs a new Command
for launching the program at path program
on the remote
host.
The returned Command
is a builder, with the following default configuration:
- No arguments to the program
- Inherit the current process's environment
- Inherit the current process's working directory
- Inherit stdin/stdout/stderr for
spawn
orstatus
, but create pipes foroutput
Builder methods are provided to change these defaults and otherwise configure the process.
If program
is not an absolute path, the PATH
will be searched in an OS-defined way on
the host.
pub fn close(self) -> Result<(), Error>
[src]
Terminate the remote connection.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,