{"id":16376752,"url":"https://github.com/wiktor-k/ssh-agent-lib","last_synced_at":"2025-07-20T21:35:16.658Z","repository":{"id":40484557,"uuid":"450471192","full_name":"wiktor-k/ssh-agent-lib","owner":"wiktor-k","description":"A collection of types for writing custom SSH agents.","archived":false,"fork":false,"pushed_at":"2025-01-20T14:48:34.000Z","size":502,"stargazers_count":27,"open_issues_count":6,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-15T06:07:41.531Z","etag":null,"topics":["agent","rust","ssh"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ssh-agent-lib","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"sekey/ssh-agent.rs","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wiktor-k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"wiktor-k"}},"created_at":"2022-01-21T11:50:22.000Z","updated_at":"2025-05-11T15:30:20.000Z","dependencies_parsed_at":"2024-04-02T11:25:01.777Z","dependency_job_id":"a61e3f59-66dc-4303-86cf-421936b286a4","html_url":"https://github.com/wiktor-k/ssh-agent-lib","commit_stats":null,"previous_names":["wiktor-k/ssh-agent.rs"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/wiktor-k/ssh-agent-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiktor-k%2Fssh-agent-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiktor-k%2Fssh-agent-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiktor-k%2Fssh-agent-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiktor-k%2Fssh-agent-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiktor-k","download_url":"https://codeload.github.com/wiktor-k/ssh-agent-lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiktor-k%2Fssh-agent-lib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265612369,"owners_count":23798062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","rust","ssh"],"created_at":"2024-10-11T03:26:01.712Z","updated_at":"2025-07-20T21:35:16.626Z","avatar_url":"https://github.com/wiktor-k.png","language":"Rust","funding_links":["https://github.com/sponsors/wiktor-k"],"categories":[],"sub_categories":[],"readme":"# ssh-agent-lib\n\n[![CI](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/rust.yml/badge.svg)](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/rust.yml)\n[![Crates.io](https://img.shields.io/crates/v/ssh-agent-lib)](https://crates.io/crates/ssh-agent-lib)\n\nA collection of types for writing custom SSH agents and connecting to existing ones.\n\nThe types in this crate closely follow the [SSH Agent Protocol Internet Draft](https://datatracker.ietf.org/doc/html/draft-miller-ssh-agent) specification and can be used to utilize remote keys not supported by the default OpenSSH agent.\n\n## Examples\n\nThe following examples show a sample agent and a sample client.\nFor more elaborate example see the `examples` directory or [crates using `ssh-agent-lib`](https://crates.io/crates/ssh-agent-lib/reverse_dependencies).\n\n### Agent\n\nThe following example starts listening on a socket and processing requests.\nOn Unix it uses `ssh-agent.sock` Unix domain socket while on Windows it uses a named pipe `\\\\.\\pipe\\agent`.\n\n```rust,no_run\n#[cfg(not(windows))]\nuse tokio::net::UnixListener as Listener;\n#[cfg(windows)]\nuse ssh_agent_lib::agent::NamedPipeListener as Listener;\nuse ssh_agent_lib::error::AgentError;\nuse ssh_agent_lib::agent::{Session, listen};\nuse ssh_agent_lib::proto::{Identity, SignRequest};\nuse ssh_key::{Algorithm, Signature};\n\n#[derive(Default, Clone)]\nstruct MyAgent;\n\n#[ssh_agent_lib::async_trait]\nimpl Session for MyAgent {\n    async fn request_identities(\u0026mut self) -\u003e Result\u003cVec\u003cIdentity\u003e, AgentError\u003e {\n        Ok(vec![ /* public keys that this agent knows of */ ])\n    }\n\n    async fn sign(\u0026mut self, request: SignRequest) -\u003e Result\u003cSignature, AgentError\u003e {\n        // get the signature by signing `request.data`\n        let signature = vec![];\n        Ok(Signature::new(\n             Algorithm::new(\"algorithm\").map_err(AgentError::other)?,\n             signature,\n        ).map_err(AgentError::other)?)\n    }\n}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    #[cfg(not(windows))]\n    let socket = \"ssh-agent.sock\";\n    #[cfg(windows)]\n    let socket = r\"\\\\.\\pipe\\agent\";\n\n    let _ = std::fs::remove_file(socket); // remove the socket if exists\n\n    listen(Listener::bind(socket)?, MyAgent::default()).await?;\n    Ok(())\n}\n```\n\nNow, point your OpenSSH client to this socket using `SSH_AUTH_SOCK` environment variable and it will transparently use the agent:\n\n```sh\nSSH_AUTH_SOCK=ssh-agent.sock ssh user@example.com\n```\n\nOn Windows the path of the pipe has to be used:\n\n```sh\nSSH_AUTH_SOCK=\\\\.\\pipe\\agent ssh user@example.com\n```\n\n### Client\n\nThe following example connects to the agent pointed to by the `SSH_AUTH_SOCK` environment variable and prints identities (public keys) that the agent knows of:\n\n```rust,no_run\nuse service_binding::Binding;\nuse ssh_agent_lib::client::connect;\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    #[cfg(unix)]\n    let mut client =\n        connect(Binding::FilePath(std::env::var(\"SSH_AUTH_SOCK\")?.into()).try_into()?)?;\n\n    #[cfg(windows)]\n    let mut client =\n        connect(Binding::NamedPipe(std::env::var(\"SSH_AUTH_SOCK\")?.into()).try_into()?)?;\n\n    eprintln!(\n        \"Identities that this agent knows of: {:#?}\",\n        client.request_identities().await?\n    );\n\n    Ok(())\n}\n```\n\n## License\n\nThis project is licensed under either of:\n\n  - [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0),\n  - [MIT license](https://opensource.org/licenses/MIT).\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n### Note\n\nThis library has been forked from [sekey/ssh-agent.rs](https://github.com/sekey/ssh-agent.rs) as the upstream seems not be maintained (at least as of 2022).\nThe library was previously licensed under MIT, however in [#36], we relicensed it to MIT/Apache 2.0.\n\nContributors gave their approval for relicensing [#36] [screenshot]\n\n[#36]: https://github.com/wiktor-k/ssh-agent-lib/pull/36\n[screenshot]: http://web.archive.org/web/20240408190456/https://github.com/wiktor-k/ssh-agent-lib/pull/36\n\nWhat remains from the original library is considered minor and does not count for copyright assignment.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiktor-k%2Fssh-agent-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiktor-k%2Fssh-agent-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiktor-k%2Fssh-agent-lib/lists"}