importSshPublicKey
importSshPublicKey
Import an OpenSSH public-key line (<type> <base64> [comment]).
Reads ssh-rsa, ssh-ed25519, and ecdsa-sha2-nistp256/384/521 keys as written by ssh-keygen into .pub files. The line key type must equal the type inside the blob (RFC 4253 §6.6), an ECDSA curve identifier must equal its key type suffix (RFC 5656 §3.1), and trailing data after the blob is rejected. Fields are separated by spaces or tabs, one trailing line break is allowed, and everything after the base64 field is the comment. authorized_keys options and SSH certificate types are not read.
Input is capped at 16 KiB and RSA moduli at 16384 bits. input is never modified.
ts
function importSshPublicKey(
input: string | Uint8Array,
options: SshImportOptions,
): Promise<SshResult<ImportedSshPublicKey>>Parameters
input:string|Uint8Array— The line as text or UTF-8 bytesoptions:SshImportOptions— Policy options; seeSshImportOptions
Returns — The WebCrypto verification key, its comment and its SHA-256 fingerprint
See also
importSshPublicKeyOrThrowfor the throwing variantexportSshPublicKeyfor the inverse operation