Property ForwardAgentFilter
- Namespace
- SshSharp
- Assembly
- SshSharp.dll
ForwardAgentFilter
Decides each request a program on the server makes of the forwarded agent (ForwardAgent): which keys it lists and
whether each signature is made. Return true to allow. It can be asynchronous, to ask the user (as ssh-add -c does) or
another service. Null (the default) allows everything, as ssh -A does.
public Func<SshAgentRequest, CancellationToken, ValueTask<bool>>? ForwardAgentFilter { get; init; }
Property Value
Remarks
The filter is asked once for each key in a listing (ListKeys; a refused key is left out) and
for every signature (Sign; a refused one is answered with SSH_AGENT_FAILURE, as an agent
whose user declines a confirmation answers). A key is checked again when it signs, whether or not it was listed: a public key is no
secret, so hiding it does not stop a request for it. To confirm each use as ssh-add -c does, allow every listing and ask
on Sign.
With a filter, the forwarded agent is read-only and narrowed: requests to add, remove or lock keys are refused, RSA keys never sign with SHA-1, and keys whose type SshPublicKey does not read are hidden. Without one, a real agent's connection is relayed byte for byte, as before.
Data to sign that is not a login request, an SSH signature or a certificate reaches the filter with a null Purpose: programs sign their own formats through agents (pam_ssh_agent_auth, for one), so it is the filter's to allow. Allowing only the purposes the application knows keeps a forwarded agent from signing anything else.
It runs on the connection's background work, possibly for several agent channels at once; it gets a token that is cancelled when the connection closes. Anything it throws refuses the request (and is logged). It is not asked for this client's own authentication through the agent, only for requests that come through agent forwarding.