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)
7
8
9
10
11
12
13
14
15
16
17
fn main() -> Result<()> {
    let path = env::var("SSH_AUTH_SOCK").expect("SSH_AUTH_SOCK is not set");
    let client = Client::connect(Path::new(path.as_str()))?;

    let authorized_keys_path = env::args().nth(1).expect("argument missing");

    let result = authenticate(authorized_keys_path.as_str(), client, &mut PrintLog {})?;

    println!("Status of authentication is: {}", result);
    Ok(())
}