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
impl ConnectOptions
Sourcepub fn append_known_hosts_from_file(
self,
known_hosts_file: impl AsRef<Path>,
) -> Result<Self, Error>
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.
Sourcepub fn client_auth_agent_sock(self, agent_sock: impl Into<PathBuf>) -> Self
pub fn client_auth_agent_sock(self, agent_sock: impl Into<PathBuf>) -> Self
Sets the path to an OpenSSH agent socket for client authentication.
Sourcepub fn client_auth_public_key(
self,
public_key: impl Into<String>,
) -> Result<Self, Error>
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.
Sourcepub fn user(self, user: impl Into<String>) -> Self
pub fn user(self, user: impl Into<String>) -> Self
Sets the username on the remote host for the client.
Sourcepub fn target(hostname: String, port: u16) -> Self
pub fn target(hostname: String, port: u16) -> Self
Sets the target host and a port number to use when connecting.
Sourcepub async fn connect(self) -> Result<Session, Error>
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.