Add SshAgentServer for hosting keys over the agent protocol - #52
Open
darinkes wants to merge 1 commit into
Open
Conversation
SshAgentServer holds SSH.NET keys and answers the agent protocol (list and sign) over a unix domain socket or a Windows named pipe, so any SSH client can use in-process keys. Signing uses the loaded keys, honouring the RFC 8332 RSA sha2 sign flags. Supports list, sign, remove, remove-all, lock and unlock; adding keys over the protocol is refused. Keys are managed through the .NET API. The endpoint is a signing authority, so it is restricted to the current user: the unix socket is created owner-only (0600) on .NET 7+ and removed on dispose, and the Windows named pipe is created with a current-user-only ACL. Tested through the library's own client (list, sign/verify for RSA, ECDSA and Ed25519, lock, remove) and end-to-end against a real SSH server.
darinkes
force-pushed
the
feat/agent-server
branch
from
July 20, 2026 08:34
dc4914e to
b3d4238
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SshAgentServer, a minimal in-process ssh-agent. It holds SSH.NET keys and answers the agent protocol — identity listing and signing — over a unix domain socket (off Windows) or a Windows named pipe, so any SSH client (this library's ownSshAgent,ssh,git, …) can use keys hosted by a .NET process. Because signing is done in-process with the loaded keys, the key material can come from anywhere the process can reach: a file, a freshly generated key, or an HSM/Key Vault wrapper.This turns the library from an agent client into a small agent toolkit, and is the building block for Key Vault-backed agents, Pageant replacements and WSL↔Windows bridges.
API
Protocol coverage
SSH2_AGENTC_REQUEST_IDENTITIES→ lists the held keys (empty while locked)SSH2_AGENTC_SIGN_REQUEST→ signs with the matching key, honouring the RFC 8332 RSA sha2 sign flagsSSH2_AGENTC_REMOVE_IDENTITY/REMOVE_ALL_IDENTITIESSSH_AGENTC_LOCK/UNLOCKADD_IDENTITY) →SSH_AGENT_FAILUREKeys are managed through the .NET API; pushing a key in over the protocol (
ssh-add) is intentionally out of scope for now. Unix domain sockets need the netstandard2.1 or .NET build (same as the client).Tests
SshAgentServerTestsdrives the server through the library's ownSshAgentclient over a real socket/pipe:Full suite: 53 passed, 18 environment-skipped (Docker / Pageant / OS agent), 0 failed. All target frameworks build.