Table of Contents

Method ToOpenSshPrivateKey

Namespace
SshSharp
Assembly
SshSharp.dll

ToOpenSshPrivateKey(string?, int)

The key in the OpenSSH private key format (BEGIN OPENSSH PRIVATE KEY), as ssh-keygen writes it: encrypted with aes256-ctr and bcrypt_pbkdf when passphrase is given, otherwise unencrypted. The text holds the private key: do not log it, and write it only to files other users cannot read (SaveAsync(string, string?, CancellationToken) does).

public string ToOpenSshPrivateKey(string? passphrase = null, int kdfRounds = 16)

Parameters

passphrase string

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

kdfRounds int

bcrypt_pbkdf rounds (ssh-keygen -a): 16 by default; more make guessing the passphrase slower, and loading the key too.

Returns

string

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).