pub struct SSH2Channel { /* private fields */ }
Expand description

A channel represents a portion of an SSH connection on which data can be read and written.

Channels denote all of SCP uploads and downloads, shell sessions, remote process executions, and other general-purpose sessions. Each channel implements the Reader and Writer traits to send and receive data. Whether or not I/O operations are blocking is mandated by the blocking flag on a channel’s corresponding Session.

Implementations§

Set an environment variable in the remote channel’s process space.

Note that this does not make sense for all channel types and may be ignored by the server despite returning success.

Request a PTY on an established channel.

Note that this does not make sense for all channel types and may be ignored by the server despite returning success.

The dimensions argument is a tuple of (width, height, width_px, height_px)

The mode parameter is optional and specifies modes to apply to the pty. Use the PtyModes type construct these modes. A contrived example of this is below:

let mut mode = ssh2::PtyModes::new();
// Set the interrupt character to CTRL-C (ASCII 3: ETX).
// This is typically the default, but we're showing how to
// set a relatable option for the sake of example!
mode.set_character(ssh2::PtyModeOpcode::VINTR, Some(3 as char));

Request that the PTY size be changed to the specified size. width and height are the number of character cells, and you may optionally include the size specified in pixels.

Requests that the remote host start an authentication agent; if successful requests to that agent will be forwarded from the server back to the local authentication agent on the client side.

Note that some hosts are configured to disallow agent forwarding, and that even if enabled, there is a possibility that starting the agent on the remote system can fail.

Execute a command

An execution is one of the standard process services defined by the SSH2 protocol.

Example
let mut channel = session.channel_session().unwrap();
channel.exec("ls").unwrap();
let mut s = String::new();
channel.read_to_string(&mut s).unwrap();
println!("{}", s);

Start a shell

A shell is one of the standard process services defined by the SSH2 protocol.

Request a subsystem be started.

A subsystem is one of the standard process services defined by the SSH2 protocol.

Initiate a request on a session type channel.

The SSH2 protocol currently defines shell, exec, and subsystem as standard process services.

Get a handle to the stderr stream of this channel.

The returned handle implements the Read and Write traits.

Get a handle to a particular stream for this channel.

The returned handle implements the Read and Write traits.

Groups of substreams may be flushed by passing one of the following constants and then calling flush().

  • FLUSH_EXTENDED_DATA - Flush all extended data substreams
  • FLUSH_ALL - Flush all substreams

Change how extended data (such as stderr) is handled

Returns the exit code raised by the process running on the remote host at the other end of the named channel.

Note that the exit status may not be available if the remote end has not yet set its status to closed.

Get the remote exit signal.

Check the status of the read window.

Check the status of the write window.

Adjust the receive window for a channel by adjustment bytes.

If the amount to be adjusted is less than the minimum adjustment and force is false, the adjustment amount will be queued for a later packet.

This function returns the new size of the receive window (as understood by remote end) on success.

Check if the remote host has sent an EOF status for the channel. Take care: the EOF status is for the entire channel which can be confusing because the reading from the channel reads only the stdout stream. unread, buffered, stderr data will cause eof() to return false.

Tell the remote host that no further data will be sent on the specified channel.

Processes typically interpret this as a closed stdin descriptor.

Wait for the remote end to send EOF. Note that unread buffered stdout and stderr will cause this function to return Ok(()) without waiting. You should call the eof() function after calling this to check the status of the channel.

Close an active data channel.

In practice this means sending an SSH_MSG_CLOSE packet to the remote host which serves as instruction that no further data will be sent to it. The remote host may still send data back until it sends its own close message in response.

To wait for the remote end to close its connection as well, follow this command with wait_closed

Enter a temporary blocking state until the remote host closes the named channel.

Typically sent after close in order to examine the exit status.

Trait Implementations§

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
Read all bytes until EOF in this source, placing them into buf. Read more
Read all bytes until EOF in this source, appending them to buf. Read more
Read the exact number of bytes required to fill buf. Read more
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Transforms this Read instance to an Iterator over its bytes. Read more
Creates an adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Like write, except that it writes from a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Attempts to write an entire buffer into this writer. Read more
🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
The error type produced by a failed conversion.
Convert the given value into an approximately equivalent representation.
The error type produced by a failed conversion.
Convert the subject into an approximately equivalent representation.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Approximate the subject with the default scheme.
Approximate the subject with a specific scheme.
Approximate the subject to a given type with the default scheme.
Approximate the subject to a given type with a specific scheme.
Convert the subject to a given type.
Attempt to convert the subject to a given type.
Attempt a value conversion of the subject to a given type.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Reads an unsigned 8 bit integer from the underlying reader. Read more
Reads a signed 8 bit integer from the underlying reader. Read more
Reads an unsigned 16 bit integer from the underlying reader. Read more
Reads a signed 16 bit integer from the underlying reader. Read more
Reads an unsigned 24 bit integer from the underlying reader. Read more
Reads a signed 24 bit integer from the underlying reader. Read more
Reads an unsigned 32 bit integer from the underlying reader. Read more
Reads a signed 32 bit integer from the underlying reader. Read more
Reads an unsigned 48 bit integer from the underlying reader. Read more
Reads a signed 48 bit integer from the underlying reader. Read more
Reads an unsigned 64 bit integer from the underlying reader. Read more
Reads a signed 64 bit integer from the underlying reader. Read more
Reads an unsigned 128 bit integer from the underlying reader. Read more
Reads a signed 128 bit integer from the underlying reader. Read more
Reads an unsigned n-bytes integer from the underlying reader. Read more
Reads a signed n-bytes integer from the underlying reader. Read more
Reads an unsigned n-bytes integer from the underlying reader.
Reads a signed n-bytes integer from the underlying reader.
Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more
Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more
Reads a sequence of unsigned 16 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 32 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 64 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 128 bit integers from the underlying reader. Read more
Reads a sequence of signed 8 bit integers from the underlying reader. Read more
Reads a sequence of signed 16 bit integers from the underlying reader. Read more
Reads a sequence of signed 32 bit integers from the underlying reader. Read more
Reads a sequence of signed 64 bit integers from the underlying reader. Read more
Reads a sequence of signed 128 bit integers from the underlying reader. Read more
Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the underlying reader. Read more
👎Deprecated since 1.2.0: please use read_f32_into instead
DEPRECATED. Read more
Reads a sequence of IEEE754 double-precision (8 bytes) floating point numbers from the underlying reader. Read more
👎Deprecated since 1.2.0: please use read_f64_into instead
DEPRECATED. Read more
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read into the supplied reference. Acts the same as std::io::Read::read_exact.
Read the byte value of the inferred type
Read the byte value of the inferred type
Read the byte value of the inferred type
Should always be Self
Sets value as a parameter of self.
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The error type produced by a failed conversion.
Convert the given value into the subject type.
The type returned in the event of a conversion error.
Performs the conversion.
The error type produced by a failed conversion.
Convert the subject into the destination type.
The type returned in the event of a conversion error.
Performs the conversion.
The error type produced by a failed conversion.
Convert the given value into an exactly equivalent representation.
The error type produced by a failed conversion.
Convert the subject into an exactly equivalent representation.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Writes an unsigned 8 bit integer to the underlying writer. Read more
Writes a signed 8 bit integer to the underlying writer. Read more
Writes an unsigned 16 bit integer to the underlying writer. Read more
Writes a signed 16 bit integer to the underlying writer. Read more
Writes an unsigned 24 bit integer to the underlying writer. Read more
Writes a signed 24 bit integer to the underlying writer. Read more
Writes an unsigned 32 bit integer to the underlying writer. Read more
Writes a signed 32 bit integer to the underlying writer. Read more
Writes an unsigned 48 bit integer to the underlying writer. Read more
Writes a signed 48 bit integer to the underlying writer. Read more
Writes an unsigned 64 bit integer to the underlying writer. Read more
Writes a signed 64 bit integer to the underlying writer. Read more
Writes an unsigned 128 bit integer to the underlying writer.
Writes a signed 128 bit integer to the underlying writer.
Writes an unsigned n-bytes integer to the underlying writer. Read more
Writes a signed n-bytes integer to the underlying writer. Read more
Writes an unsigned n-bytes integer to the underlying writer. Read more
Writes a signed n-bytes integer to the underlying writer. Read more
Writes a IEEE754 single-precision (4 bytes) floating point number to the underlying writer. Read more
Writes a IEEE754 double-precision (8 bytes) floating point number to the underlying writer. Read more
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it
Write the byte value of the specified reference, converting it to little endianness
Write the byte value of the specified reference, converting it to big endianness
Write the byte value of the specified reference, not converting it