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
pathstringThe private key file, for example
~/.ssh/id_ed25519.passphrasestringThe passphrase to encrypt with; null or empty for an unencrypted key.
cancellationTokenCancellationTokenCancels writing.
Returns
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).