Table of Contents

Method SaveAsync

Namespace
SshSharp
Assembly
SshSharp.dll

SaveAsync(string, string?, CancellationToken)

Writes the key as ssh-keygen does: the private key to path (ToOpenSshPrivateKey(string?, int)), readable only by the current user (mode 0600 on Unix, an owner-only ACL on Windows), and the public key to path.pub. Neither file may exist yet: an existing key is never overwritten.

public Task SaveAsync(string path, string? passphrase = null, CancellationToken cancellationToken = default)

Parameters

path string

The private key file, for example ~/.ssh/id_ed25519.

passphrase string

The passphrase to encrypt with; null or empty for an unencrypted key.

cancellationToken CancellationToken

Cancels writing.

Returns

Task

Exceptions

IOException

One of the files exists already, or could not be written.

NotSupportedException

The private key is not available: a key held by an agent or an external signer, or one paired with a certificate (export the key it was made from).