Method ToPuttyPrivateKey
- Namespace
- SshSharp
- Assembly
- SshSharp.dll
ToPuttyPrivateKey(string?)
The key as a PuTTY key file (.ppk, version 3), as PuTTYgen 0.75 and later writes it: when passphrase is
given, encrypted with AES-256-CBC under a key from Argon2id (46 MiB, one pass), otherwise unencrypted; authenticated with
HMAC-SHA256 either way. PuTTY, Pageant and WinSCP read it; versions of PuTTY before 0.75 do not. The text holds the private key:
do not log it, and write it only to files other users cannot read
(SaveAsync(string, SshPrivateKeyFormat, string?, CancellationToken) does).
public string ToPuttyPrivateKey(string? passphrase = null)
Parameters
passphrasestringThe passphrase to encrypt with; null or empty for an unencrypted key.
Returns
Exceptions
- 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). Or the Comment has a line break, which a
.ppkfile cannot hold.