Table of Contents

Method AddKeyAsync

Namespace
SshSharp
Assembly
SshSharp.dll

AddKeyAsync(SshPrivateKey, SshAgentKeyConstraints?, CancellationToken)

Adds key to the agent, as ssh-add does, optionally with constraints (a lifetime, or a confirmation for each use). A key paired with a certificate is added with it. Adding a key the agent already holds replaces its constraints.

public Task AddKeyAsync(SshPrivateKey key, SshAgentKeyConstraints? constraints = null, CancellationToken cancellationToken = default)

Parameters

key SshPrivateKey
constraints SshAgentKeyConstraints
cancellationToken CancellationToken

Returns

Task

Exceptions

NotSupportedException

The key's private material is not here: it is held by an agent already.

SshException

The agent is not running or refused the key (AgentFailed), for example a key type or constraint it does not support, or a locked agent.