Struct ConnectOptions

Source
pub struct ConnectOptions {
    known_hosts: Vec<Entry>,
    client_auth_agent_sock: PathBuf,
    client_auth_public_key: Option<PublicKey>,
    user: String,
    hostname: String,
    port: u16,
}
Expand description

Connection options for sending a signature request.

The options capture target host parameters and all necessary information related to authentication for both the client (client’s public key and authentication agent) and server (a list of valid and known server public keys).

§Examples

use signstar_request_signature::ssh::client::ConnectOptions;

let options = ConnectOptions::target("localhost".into(), 22)
    .append_known_hosts_from_file("/home/user/.ssh/known_hosts")?
    .client_auth_agent_sock(std::env::var("SSH_AUTH_SOCK")?)
    .client_auth_public_key("ssh-ed25519 ...")?
    .user("signstar");

Fields§

§known_hosts: Vec<Entry>§client_auth_agent_sock: PathBuf§client_auth_public_key: Option<PublicKey>§user: String§hostname: String§port: u16

Implementations§

Source§

impl ConnectOptions

Source

pub fn append_known_hosts_from_file( self, known_hosts_file: impl AsRef<Path>, ) -> Result<Self, Error>

Adds known hosts from a file containing data in the SSH known_hosts file format.

§Errors

Returns an error if the file is badly formatted or reading the file fails.

Source

pub fn client_auth_agent_sock(self, agent_sock: impl Into<PathBuf>) -> Self

Sets the path to an OpenSSH agent socket for client authentication.

Source

pub fn client_auth_public_key( self, public_key: impl Into<String>, ) -> Result<Self, Error>

Sets an SSH public key of a client for SSH authentication.

§Examples
use signstar_request_signature::ssh::client::ConnectOptions;

let options = ConnectOptions::target("localhost".into(), 22)
    .client_auth_public_key(
        "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILHCXBJYlPPkrt2WYyP3SZoMx43lDBB5QALjE762EQlc",
    )?
    .user("signstar");
§Errors

Returns an error if the public key is not well-formatted. This function only accepts public keys following the authorized_keys file format.

Source

pub fn user(self, user: impl Into<String>) -> Self

Sets the username on the remote host for the client.

Source

pub fn target(hostname: String, port: u16) -> Self

Sets the target host and a port number to use when connecting.

Source

pub async fn connect(self) -> Result<Session, Error>

Connects to a host over SSH and returns a Session object.

This function sets up an authenticated, bidirectional channel between the client and the server. No signing requests are exchanged at this point but any number of them can be issued later using Session::send function.

§Examples
use signstar_request_signature::ssh::client::ConnectOptions;

let options = ConnectOptions::target("localhost".into(), 22);

let mut session = options.connect().await?;
// use session to send signing requests
§Errors

Returns an error if:

  • the client public key is not set,
  • the server public key is not present in the provided SSH known_hosts data,
  • the client public key is not recognized by the server,
  • the client authentication with the agent fails,
  • an SSH protocol error is encountered.

Trait Implementations§

Source§

impl Debug for ConnectOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConnectOptions

Source§

fn default() -> ConnectOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V