Struct openssh::SessionBuilder
source · pub struct SessionBuilder { /* private fields */ }
Expand description
Build a Session
with options.
Implementations§
source§impl SessionBuilder
impl SessionBuilder
sourcepub fn port(&mut self, port: u16) -> &mut Self
pub fn port(&mut self, port: u16) -> &mut Self
Set the port to connect on (ssh -p
).
Defaults to None
.
sourcepub fn keyfile(&mut self, p: impl AsRef<Path>) -> &mut Self
pub fn keyfile(&mut self, p: impl AsRef<Path>) -> &mut Self
Set the keyfile to use (ssh -i
).
Defaults to None
.
sourcepub fn known_hosts_check(&mut self, k: KnownHosts) -> &mut Self
pub fn known_hosts_check(&mut self, k: KnownHosts) -> &mut Self
See KnownHosts
.
Default KnownHosts::Add
.
sourcepub fn connect_timeout(&mut self, d: Duration) -> &mut Self
pub fn connect_timeout(&mut self, d: Duration) -> &mut Self
Set the connection timeout (ssh -o ConnectTimeout
).
This value is specified in seconds. Any sub-second duration remainder will be ignored.
Defaults to None
.
sourcepub fn server_alive_interval(&mut self, d: Duration) -> &mut Self
pub fn server_alive_interval(&mut self, d: Duration) -> &mut Self
Set the timeout interval after which if no data has been received from the server, ssh
will request a response from the server (ssh -o ServerAliveInterval
).
This value is specified in seconds. Any sub-second duration remainder will be ignored.
Defaults to None
.
sourcepub fn control_directory(&mut self, p: impl AsRef<Path>) -> &mut Self
pub fn control_directory(&mut self, p: impl AsRef<Path>) -> &mut Self
Set the directory in which the temporary directory containing the control socket will be created.
If not set, ./
will be used (the current directory).
sourcepub fn config_file(&mut self, p: impl AsRef<Path>) -> &mut Self
pub fn config_file(&mut self, p: impl AsRef<Path>) -> &mut Self
Set an alternative per-user configuration file.
By default, ssh uses ~/.ssh/config
. This is equivalent to ssh -F <p>
.
Defaults to None
.
sourcepub fn compression(&mut self, compression: bool) -> &mut Self
pub fn compression(&mut self, compression: bool) -> &mut Self
Enable or disable compression (including stdin, stdout, stderr, data for forwarded TCP and unix-domain connections, sftp and scp connections).
Note that the ssh server can forcibly disable the compression.
By default, ssh uses configure value set in ~/.ssh/config
.
If ~/.ssh/config
does not enable compression, then it is disabled
by default.
sourcepub fn jump_hosts<T: AsRef<str>>(
&mut self,
hosts: impl IntoIterator<Item = T>,
) -> &mut Self
pub fn jump_hosts<T: AsRef<str>>( &mut self, hosts: impl IntoIterator<Item = T>, ) -> &mut Self
Specify one or multiple jump hosts.
Connect to the target host by first making a ssh connection to the jump host described by destination and then establishing a TCP forwarding to the ultimate destination from there.
Multiple jump hops may be specified. This is a shortcut to specify a ProxyJump configuration directive.
Note that configuration directives specified by SessionBuilder
do not apply to the jump hosts.
Use ~/.ssh/config to specify configuration for jump hosts.
sourcepub fn user_known_hosts_file(
&mut self,
user_known_hosts_file: impl AsRef<Path>,
) -> &mut Self
pub fn user_known_hosts_file( &mut self, user_known_hosts_file: impl AsRef<Path>, ) -> &mut Self
Specify the path to the known_hosts
file.
The path provided may use tilde notation (~
) to refer to the user’s
home directory.
The default is ~/.ssh/known_hosts
and ~/.ssh/known_hosts2
.
sourcepub fn ssh_auth_sock(&mut self, ssh_auth_sock: impl AsRef<Path>) -> &mut Self
pub fn ssh_auth_sock(&mut self, ssh_auth_sock: impl AsRef<Path>) -> &mut Self
Specify the path to the ssh-agent.
The path provided may use tilde notation (~
) to refer to the user’s
home directory.
The default is None
.
sourcepub async fn connect_mux<S: AsRef<str>>(
&self,
destination: S,
) -> Result<Session, Error>
pub async fn connect_mux<S: AsRef<str>>( &self, destination: S, ) -> Result<Session, Error>
Connect to the host at the given host
over SSH using native mux, which will
create a new local socket connection for each Child
created.
See the crate-level documentation for more details on the difference between native and process-based mux.
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]
.
A username or port that is specified in the connection string overrides the one set in the
builder (but does not change the builder).
If connecting requires interactive authentication based on STDIN
(such as reading a
password), the connection will fail. Consider setting up keypair-based authentication
instead.
Trait Implementations§
source§impl Clone for SessionBuilder
impl Clone for SessionBuilder
source§fn clone(&self) -> SessionBuilder
fn clone(&self) -> SessionBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SessionBuilder
impl Debug for SessionBuilder
Auto Trait Implementations§
impl Freeze for SessionBuilder
impl RefUnwindSafe for SessionBuilder
impl Send for SessionBuilder
impl Sync for SessionBuilder
impl Unpin for SessionBuilder
impl UnwindSafe for SessionBuilder
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)