#ssh #agent #lib #ssh-agent

ssh-agent-lib

A collection of types for writing custom SSH agents

3 releases

Uses new Rust 2021

0.2.5 May 10, 2022
0.2.4 Apr 22, 2022
0.2.3 Mar 28, 2022

#309 in Data structures

Download history 5/week @ 2022-08-11 38/week @ 2022-08-18 60/week @ 2022-08-25 10/week @ 2022-09-01 15/week @ 2022-09-08 4/week @ 2022-09-15 10/week @ 2022-09-22 15/week @ 2022-09-29 12/week @ 2022-10-06 5/week @ 2022-10-13 7/week @ 2022-10-20 12/week @ 2022-10-27 18/week @ 2022-11-03 16/week @ 2022-11-10 18/week @ 2022-11-17 19/week @ 2022-11-24

73 downloads per month
Used in 2 crates

MIT license

48KB
1.5K SLoC

ssh-agent-lib

A collection of types for writing custom SSH agents.

This makes it possible to utilize remote keys not supported by the default OpenSSH agent.

Example

This example starts listening on a Unix socket connect.sock and processes requests.

use ssh_agent_lib::agent::Agent;
use ssh_agent_lib::proto::message::{Message, SignRequest};

struct MyAgent;

impl Agent for MyAgent {
    type Error = ();

    fn handle(&self, message: Message) -> Result<Message, ()> {
        match message {
            Message::SignRequest(request) => {
                // get the signature by signing `request.data`
                let signature = vec![];
                Ok(Message::SignResponse(signature))
            },
            _ => Ok(Message::Failure),
        }
    }
}

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let agent = MyAgent;
    let socket = "connect.sock";
    let _ = std::fs::remove_file(socket);

    agent.run_unix(socket)?;
    Ok(())
}

For more elaborate example see examples directory.

Note

This library has been forked from sekey/ssh-agent.rs as the upstream seems not be maintained (at least as of 2022).

Dependencies

~0.4–2.1MB
~40K SLoC