Struct ssh2::Session [] [src]

pub struct Session { /* fields omitted */ }

An SSH session, typically representing one TCP connection.

All other structures are based on an SSH session and cannot outlive a session. Sessions are created and then have the TCP socket handed to them (via the handshake method).

Methods

impl Session
[src]

[src]

Initializes an SSH session object.

This function does not associate the session with a remote connection just yet. Various configuration options can be set such as the blocking mode, compression, sigpipe, the banner, etc. To associate this session with a TCP connection, use the handshake method to pass in an already-established TCP socket.

[src]

Set the SSH protocol banner for the local client

Set the banner that will be sent to the remote host when the SSH session is started with handshake(). This is optional; a banner corresponding to the protocol and libssh2 version will be sent by default.

[src]

Flag indicating whether SIGPIPE signals will be allowed or blocked.

By default (on relevant platforms) this library will attempt to block and catch SIGPIPE signals. Setting this flag to true will cause the library to not attempt to block SIGPIPE from the underlying socket layer.

[src]

Flag indicating whether this library will attempt to negotiate compression.

If set - before the connection negotiation is performed - libssh2 will try to negotiate compression enabling for this connection. By default libssh2 will not attempt to use compression.

[src]

Set or clear blocking mode on session

This will instantly affect any channels associated with this session. If a read is performed on a session with no data currently available, a blocking session will wait for data to arrive and return what it receives. A non-blocking session will return immediately with an empty buffer. If a write is performed on a session with no room for more data, a blocking session will wait for room. A non-blocking session will return immediately without writing anything.

[src]

Returns whether the session was previously set to nonblocking.

[src]

Set timeout for blocking functions.

Set the timeout in milliseconds for how long a blocking the libssh2 function calls may wait until they consider the situation an error and return an error.

By default or if you set the timeout to zero, libssh2 has no timeout for blocking functions.

[src]

Returns the timeout, in milliseconds, for how long blocking calls may wait until they time out.

A timeout of 0 signifies no timeout.

[src]

Begin transport layer protocol negotiation with the connected host.

This session does not take ownership of the socket provided, it is recommended to ensure that the socket persists the lifetime of this session to ensure that communication is correctly performed.

It is also highly recommended that the stream provided is not used concurrently elsewhere for the duration of this session as it may interfere with the protocol.

[src]

Attempt basic password authentication.

Note that many SSH servers which appear to support ordinary password authentication actually have it disabled and use Keyboard Interactive authentication (routed via PAM or another authentication backed) instead.

[src]

Attempt to perform SSH agent authentication.

This is a helper method for attempting to authenticate the current connection with the first public key found in an SSH agent. If more control is needed than this method offers, it is recommended to use agent directly to control how the identity is found.

[src]

Attempt public key authentication using a PEM encoded private key file stored on disk.

[src]

Attempt public key authentication using a PEM encoded private key from memory. Public key is computed from private key if none passed. This is available only for unix targets, as it relies on openssl. It is therefore recommended to use #[cfg(unix)] or otherwise test for the unix compliation target when using this function.

[src]

[src]

Indicates whether or not the named session has been successfully authenticated.

[src]

Send a SSH_USERAUTH_NONE request to the remote host.

Unless the remote host is configured to accept none as a viable authentication scheme (unlikely), it will return SSH_USERAUTH_FAILURE along with a listing of what authentication schemes it does support. In the unlikely event that none authentication succeeds, this method with return an error. This case may be distinguished from a failing case by examining the return value of the authenticated method.

The return value is a comma-separated string of supported auth schemes.

[src]

Set preferred key exchange method

The preferences provided are a comma delimited list of preferred methods to use with the most preferred listed first and the least preferred listed last. If a method is listed which is not supported by libssh2 it will be ignored and not sent to the remote host during protocol negotiation.

[src]

Return the currently active algorithms.

Returns the actual method negotiated for a particular transport parameter. May return None if the session has not yet been started.

[src]

Get list of supported algorithms.

[src]

Init an ssh-agent handle.

The returned agent will still need to be connected manually before use.

[src]

Init a collection of known hosts for this session.

Returns the handle to an internal representation of a known host collection.

[src]

Establish a new session-based channel.

This method is commonly used to create a channel to execute commands over or create a new login shell.

[src]

Tunnel a TCP connection through an SSH session.

Tunnel a TCP/IP connection through the SSH transport via the remote host to a third party. Communication from the client to the SSH server remains encrypted, communication from the server to the 3rd party host travels in cleartext.

The optional src argument is the host/port to tell the SSH server where the connection originated from.

The Channel returned represents a connection between this host and the specified remote host.

[src]

Instruct the remote SSH server to begin listening for inbound TCP/IP connections.

New connections will be queued by the library until accepted by the accept method on the returned Listener.

[src]

Request a file from the remote host via SCP.

The path specified is a path on the remote host which will attempt to be sent over the returned channel. Some stat information is also returned about the remote file to prepare for receiving the file.

[src]

Send a file to the remote host via SCP.

The remote_path provided will the remote file name. The times argument is a tuple of (mtime, atime), and will default to the remote host's current time if not specified.

The size of the file, size, must be known ahead of time before transmission.

[src]

Open a channel and initialize the SFTP subsystem.

Although the SFTP subsystem operates over the same type of channel as those exported by the Channel API, the protocol itself implements its own unique binary packet protocol which must be managed with the methods on Sftp.

[src]

Allocate a new channel for exchanging data with the server.

This is typically not called directly but rather through channel_session, channel_direct_tcpip, or channel_forward_listen.

[src]

Get the remote banner

Once the session has been setup and handshake() has completed successfully, this function can be used to get the server id from the banner each server presents.

May return None on invalid utf-8 or if an error has ocurred.

[src]

See banner.

Will only return None if an error has ocurred.

[src]

Get the remote key.

Returns None if something went wrong.

[src]

Returns the computed digest of the remote system's hostkey.

The bytes returned are the raw hash, and are not printable. If the hash is not yet available None is returned.

[src]

Set how often keepalive messages should be sent.

The want_reply argument indicates whether the keepalive messages should request a response from the server.

The interval argument is number of seconds that can pass without any I/O, use 0 (the default) to disable keepalives. To avoid some busy-loop corner-cases, if you specify an interval of 1 it will be treated as 2.

[src]

Send a keepalive message if needed.

Returns how many seconds you can sleep after this call before you need to call it again.

[src]

Terminate the transport layer.

Send a disconnect message to the remote host associated with session, along with a reason symbol and a verbose description.

Note that this does not close the underlying socket.

[src]

Translate a return code into a Rust-Result.

Trait Implementations

impl Send for Session
[src]

impl Drop for Session
[src]

[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl !Sync for Session