Method FromKeys
- Namespace
- SshSharp
- Assembly
- SshSharp.dll
FromKeys(params SshPrivateKey[])
An agent served in this process from keys: key files, generated keys, keys in a Windows key store
(FromRsa(RSA, string?)), keys behind an SshKeySigner such as a cloud KMS or an HSM
(FromSigner(SshKeySigner, string?)), and keys paired with certificates (WithCertificate(SshCertificate)), which
it lists as ssh-add adds them: the key, then its certificate. Forward it with ForwardAgent
where no agent process runs (a container, a service), or to forward a key that is not in any agent.
public static SshAgent FromKeys(params SshPrivateKey[] keys)
Parameters
keysSshPrivateKey[]The keys, in the order they are listed; a key given twice is listed once.
Returns
Remarks
It speaks the agent protocol as ssh-agent does, read-only: it lists its keys and signs with them, binds connections to
sessions (session-bind@openssh.com) and answers query. Adding, removing and locking keys are refused
(AddKeyAsync(SshPrivateKey, SshAgentKeyConstraints?, CancellationToken) and the others throw SshException with AgentFailed). RSA keys
sign with rsa-sha2-256 or rsa-sha2-512 as asked, never SHA-1. Like ssh-agent, it signs whatever data it is
asked to (other programs sign their own formats through agents, pam_ssh_agent_auth for one); a key behind an
SshKeySigner sees such data as Other, and
ForwardAgentFilter can restrict what a forwarded agent signs to the purposes it knows.
The agent does not dispose the keys, and uses them until it is no longer used: keep them alive as long as the clients that forward it. Keys loaded from files hold their private key in this process's memory; a key behind an SshKeySigner never enters it.
Exceptions
- ArgumentNullException
keysor one of them is null.