exportOpenSshPrivateKey
exportOpenSshPrivateKey
Export a private key as an unencrypted openssh-key-v1 PEM file.
The file holds one key, cipher none and KDF none, with the check integers drawn from the WebCrypto random source and the public key derived from the private key. ssh-keygen reads it directly. Check integers are random, so compare keys, not file bytes, between two exports.
The private CryptoKey must be extractable. The binary encoding is zeroed after the PEM text is built; the returned string and the JWK used for the export cannot be zeroed.
ts
function exportOpenSshPrivateKey(
privateKey: CryptoKey,
options: SshExportOptions,
): Promise<string>Parameters
privateKey:CryptoKeyoptions:SshExportOptions
Throws
ResultError— Carrying anSshExportErrorCodeascode
See also
importOpenSshPrivateKeyfor the inverse operation