Function authenticate

Source
pub fn authenticate(
    keys_file_path: &str,
    agent: impl SSHAgent,
    log: &mut impl Log,
) -> Result<bool>
Expand description

Finds the first key, if any, that the ssh-agent knows about that is also present in the file referenced by keys_file_path, sends a random message to be signed and verifies the signature with the public key.

Returns Ok(true) if a key was found and the signature was correct, Ok(false) if no key was found, and Err if agent communication or signature verification failed.

Examples found in repository?
examples/authenticator.rs (line 13)
7fn main() -> Result<()> {
8    let path = env::var("SSH_AUTH_SOCK").expect("SSH_AUTH_SOCK is not set");
9    let client = Client::connect(Path::new(path.as_str()))?;
10
11    let authorized_keys_path = env::args().nth(1).expect("argument missing");
12
13    let result = authenticate(authorized_keys_path.as_str(), client, &mut PrintLog {})?;
14
15    println!("Status of authentication is: {}", result);
16    Ok(())
17}