Fact-checked by Grok 2 weeks ago

ssh-keygen

ssh-keygen is a command-line utility in the suite designed to generate, manage, and convert authentication keys for the (SSH) protocol version 2, enabling secure public key-based authentication for remote logins and file transfers. Developed as part of , which originated from the project in 1999 as an open-source reimplementation of the original SSH software, ssh-keygen has become a standard tool for in operating systems and has been integrated into Windows via for Windows. The tool supports generating key pairs in various types, including (with a default size of 3072 bits), ECDSA, ECDSA-SK (security key variant), Ed25519 (the default type for its efficiency and security), and Ed25519-SK, while support has been deprecated due to vulnerabilities. Key functionalities of ssh-keygen extend beyond generation to include changing passphrases on existing keys, modifying key comments, converting between formats such as (default for better protection), , , and RFC 4716, displaying key fingerprints for verification, screening known hosts files, generating Diffie-Hellman groups for , and managing Key Revocation Lists (KRLs) to revoke compromised keys. By default, generated private keys are stored in ~/.ssh/id_<type> with corresponding public keys in ~/.ssh/id_<type>.pub, and users are prompted to set an optional to encrypt the private key, enhancing security against unauthorized access. This comprehensive capability makes ssh-keygen essential for setting up secure, passwordless SSH access in both personal and enterprise environments.

Introduction

Overview

ssh-keygen is a command-line utility within the suite designed for generating, managing, and converting pairs of public and authentication keys used in the (SSH) protocol to enable . It supports the creation of key pairs in various formats suitable for SSH version 2, the current standard, allowing users to establish secure remote connections without transmitting passwords over the network. Among its primary functions, ssh-keygen facilitates the addition of passphrases to protect keys, modification of existing keys including type changes, and of key details such as fingerprints for verification purposes. As an integral component of , ssh-keygen is widely available on operating systems including and macOS, and has been integrated into Windows starting with version 10 build 1809 in October 2018, providing cross-platform compatibility for secure access. It is commonly employed in development workflows, such as with for authenticating secure repository cloning and pushing over SSH without requiring repeated credential entry. The tool is included in the latest release, version 10.2, distributed in October 2025, ensuring ongoing support for modern security practices across diverse environments. In a typical , a user invokes ssh-keygen to produce a private key file and its corresponding public key, which is then appended to the server's authorized_keys file for access permission; subsequent SSH client connections leverage the private key for seamless, encrypted authentication. This process underpins secure , file transfers, and automated scripting in networked systems.

History

ssh-keygen was developed as part of the original (SSH) implementation by Tatu Ylönen in 1995, following a password-sniffing incident on the network that prompted the creation of a secure alternative to tools like and rsh. The tool enabled the generation of keys for in SSH-1, which was the sole supported at the time and relied exclusively on for . The open-source project, initiated in 1999 by the team as a free alternative to the proprietary SSH implementation, incorporated ssh-keygen from its early releases, with version 2.5 in 2001 introducing support for keys alongside for the emerging SSH-2 protocol. SSH-2, standardized in 2006, marked a significant evolution by enhancing security through stronger and integrity mechanisms, while ssh-keygen adapted to generate keys for these improvements, phasing out SSH-1's RSA-only limitations by 2006 in most implementations. Key milestones in ssh-keygen's development include the addition of Ed25519 support in OpenSSH 6.5 (2014), providing faster and more secure keys resistant to certain side-channel attacks. Ed25519 was made the default key type for ssh-keygen in 9.5 (October 2023) due to its efficiency and security advantages. keys were disabled by default in 7.0 (2015) due to vulnerabilities like weak , with full removal occurring in version 10.0 (April 2025). FIDO/U2F hardware key support, via ecdsa-sk and ed25519-sk types, was introduced in 8.2 (2020), enabling security key authentication with options for resident keys and touch requirements. Recent advancements focus on post-quantum resilience and deprecations: 9.0 (2022) set a post-quantum key exchange (sntrup761x25519-sha512) as the default for connections, though ssh-keygen's key generation did not yet incorporate post-quantum algorithms. 10.0 (April 2025) updated the default to the mlkem768x25519-sha256 post-quantum key exchange for connections, while ssh-keygen gained support for inspecting and generating keys with custom hash algorithms like SHA-256 for , alongside improved FIDO2 enrollment handling. Deprecations include discouraging keys below 2048 bits since 2015 per NIST guidelines, reflected in ssh-keygen's default size increase to 3072 bits in 8.0 (2019), and the removal of signatures from default algorithms in 8.2 (2020), with further disabling in later versions like 8.8 (2021). Platform expansion came with native OpenSSH integration in Windows 10 version 1809 (October 2018), allowing ssh-keygen to generate and manage keys directly on Windows without third-party tools, extending its use to Microsoft ecosystems.

Supported Key Types

Classical Algorithms

The Rivest-Shamir-Adleman (RSA) algorithm, introduced in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman, served as the foundational public-key cryptography method for SSH key generation in ssh-keygen, particularly as the default for many years across both SSH protocol versions 1 and 2. In the RSA key generation process, two large prime numbers p and q are selected, and the modulus n = p \times q is computed, along with Euler's totient \phi(n) = (p-1)(q-1). A public exponent e is chosen such that $1 < e < \phi(n) and \gcd(e, \phi(n)) = 1, and the private exponent d is derived to satisfy the equation e \cdot d \equiv 1 \pmod{\phi(n)}, ensuring the private key d can decrypt messages encrypted with the public key (n, e). Since OpenSSH 7.8, ssh-keygen defaults to generating 3072-bit RSA keys for enhanced security against factoring attacks, though users can specify larger sizes like 4096 bits via the -b option. RSA keys maintain universal compatibility in SSH implementations due to their long-standing support and lack of deprecation. The Digital Signature Algorithm (DSA), standardized by NIST in 1994 based on earlier 1991 proposals, was incorporated into ssh-keygen primarily for SSH protocol version 2 to provide an alternative to RSA amid patent concerns. DSA keys in ssh-keygen are fixed at 1024 bits, limiting their scalability compared to variable-length RSA, and the generation command ssh-keygen -t dsa produces a private key in PEM format alongside a public key in the SSH wire format for authentication. However, DSA's reliance on a per-signature random nonce k makes it particularly susceptible to vulnerabilities from weak random number generation, where predictable k values can expose the private key after just a few signatures. NIST deprecated 1024-bit DSA in its 2013 guidance (SP 800-131A Revision 1), recommending transition away by the end of 2013 due to insufficient security margins against modern computational threats. Historically, RSA dominated initial SSH-1 deployments for its robust encryption and signature capabilities, while DSA gained traction in early SSH-2 implementations as a patent-free option until RSA patents expired in 2000. Compatibility for DSA has progressively declined; OpenSSH disabled it by default in version 7.0 (2015) due to its weaknesses, and full removal occurred in OpenSSH 10.0 (2025), rendering DSA keys unusable in modern clients without legacy reconfiguration. For classical key generation, commands like ssh-keygen -t rsa -b 4096 or ssh-keygen -t dsa (prior to deprecation) output files suitable for SSH authentication, with the private key protected by optional passphrase encryption in PEM or OpenSSH formats.

Modern and Elliptic Curve Algorithms

ssh-keygen supports modern elliptic curve-based algorithms for generating more efficient and secure key pairs compared to classical methods, with a focus on ECDSA, ECDSA-SK, Ed25519, and Ed25519-SK. These algorithms leverage the mathematical properties of elliptic curves to achieve equivalent security levels with significantly smaller key sizes, reducing computational overhead and storage requirements. ECDSA, or Elliptic Curve Digital Signature Algorithm, utilizes standardized NIST curves such as P-256, P-384, and P-521 for key generation. To create an ECDSA key pair, the command ssh-keygen -t ecdsa -b 256 specifies the type and bit length, where the -b option selects from the supported curve sizes corresponding to approximately 128, 192, or 256 bits of security. These keys are notably smaller than equivalent-strength RSA keys—for instance, a 256-bit ECDSA key provides security comparable to a 3072-bit RSA key—making them suitable for resource-constrained environments. However, ECDSA implementations are susceptible to flaws such as nonce reuse, where repeating the random nonce across signatures can compromise the private key, as demonstrated in real-world incidents like the Sony PlayStation 3 breach. Ed25519, based on the Edwards-curve Digital Signature Algorithm, employs a fixed 256-bit key size and is generated using ssh-keygen -t ed25519, with the -b option ignored due to the fixed length. It is the recommended default for new keys in modern OpenSSH implementations owing to its superior performance and security profile. Signing operations with Ed25519 are significantly faster—up to 20 times in cycle counts compared to ECDSA on NIST P-256—translating to 2-3 times faster practical signing speeds in typical SSH scenarios, while verification remains efficient. Ed25519's design uses deterministic nonce generation derived from the private key and message, resisting side-channel attacks and nonce reuse vulnerabilities that could compromise the key from past signatures, unlike random nonces in ECDSA. The mathematics underlying Ed25519 key generation derives from Curve25519, performing scalar multiplication on the twisted Edwards curve defined by the equation y^2 = x^3 + 486662 x^2 + x over the finite field \mathbb{F}_p where p = 2^{255} - 19. This curve selection ensures high-speed arithmetic and provable security properties without reliance on patented algorithms, unlike some aspects of earlier elliptic curve methods. While ECDSA remains supported for compatibility, Ed25519 is preferred for new deployments due to its balance of speed, security, and simplicity. Both algorithms are exclusively compatible with the . The SK variants (ECDSA-SK and Ed25519-SK) provide hardware-backed options generated with ssh-keygen -t ecdsa-sk or -t ed25519-sk.

Command Syntax and Options

Basic Usage

The ssh-keygen utility is invoked with the general syntax ssh-keygen followed by optional flags such as [-q] for quiet mode, [-b bits] to specify key size in bits, [-t type] to select the key algorithm type, [-f file] to set the output file path, [-C comment] to add a descriptive comment, and [-N passphrase] to provide a passphrase non-interactively. For basic key pair generation, the command ssh-keygen -t ed25519 creates an Ed25519 key pair, prompting the user for a file location (defaulting to ~/.ssh/id_ed25519 for the private key and ~/.ssh/id_ed25519.pub for the public key) and an optional passphrase for encryption. If no type is specified, ssh-keygen defaults to Ed25519 keys since OpenSSH version 9.5 released in October 2023, due to their compact size and strong security properties established in RFC 8709 and supported since OpenSSH 6.5. The generated output consists of a private key file, which must remain confidential and is never shared, and a corresponding public key file, which can be distributed to remote servers by appending its contents to the server's ~/.ssh/authorized_keys file to enable passwordless authentication. Simple management tasks include changing a key's passphrase with ssh-keygen -p, which prompts for the old passphrase, a new one, and confirmation while optionally specifying the key file with -f; or removing a host's entry from the known_hosts file using ssh-keygen -R hostname to clear cached host keys, such as after a server's key change. To support non-interactive scripting, the -q flag enables quiet mode, suppressing prompts and output except for errors, while the default Ed25519 type in modern OpenSSH versions reduces the need for explicit -t specification in basic scenarios. A typical workflow begins with generating a key pair via ssh-keygen -t ed25519, followed by copying the public key to a remote server using ssh-copy-id user@hostname (which appends the key to the server's authorized_keys after password authentication), and verifying access with ssh -i ~/.ssh/id_ed25519 user@hostname to connect using the private key.

Key Generation and Management Options

ssh-keygen provides a range of command-line options to customize the generation, modification, and inspection of SSH keys, allowing users to specify key types, sizes, file locations, and security parameters during creation or management. These options enable flexible key handling while adhering to modern cryptographic standards, with defaults optimized for security and compatibility. The -t flag selects the key type during generation, supporting ecdsa, ecdsa-sk, ed25519, ed25519-sk, or rsa, where -sk variants indicate security key (FIDO/U2F) backed keys for enhanced hardware protection; DSA support was removed in OpenSSH 10.0 due to its weaknesses, with modern deployments favoring RSA, ECDSA, or Ed25519; the default type is ed25519 for its efficiency and fixed 256-bit security level. Key size and strength are controlled via the -b flag, specifying bit lengths such as 1024, 2048, 3072, or 4096 for RSA and ECDSA keys, with RSA defaulting to 3072 bits and ECDSA to 256, 384, or 521 bits corresponding to NIST curves; Ed25519 keys use a fixed size and ignore this option. Larger bit lengths increase computational resistance to attacks but may impact performance, so 3072+ bits for RSA is recommended for long-term use. File handling options include -f to specify a custom path for the output or input key file, overriding defaults like ~/.ssh/id_<type>, and -C to add a comment such as "user@host-2025" for metadata like identification or generation date, which aids in key organization without affecting . Passphrase management uses -N to set a new directly (e.g., for batch mode without prompts) and -P to provide an existing passphrase, such as -P "" for no passphrase, though the latter is insecure and exposes keys to risks if files are compromised. Passphrases should combine uppercase, lowercase, numbers, and symbols for strength, as lost ones require regenerating keys. Additional generation flags encompass -o to enforce the new private key format, introduced in 2014 with bcrypt-based key derivation for stronger passphrase protection and better comment preservation compared to legacy . The -a option sets (KDF) rounds, defaulting to 16 for Ed25519 and adjustable (e.g., -a 32) to heighten resistance against brute-force attacks on passphrases. For key management, -y reads a private key file and outputs the corresponding public key to stdout, useful for extracting publics without manual editing. The -l flag displays a key's fingerprint, defaulting to SHA256 hash (e.g., SHA256:abc123...) for verification, while -B produces a bubblebabble-encoded digest for human-readable, error-resistant key identification. Version-specific enhancements include -K (with -w provider for the library path, e.g., -w /path/to/lib) in 8.9 and later, which facilitates PIN handling and key enrollment from hardware authenticators. As of 10.2 (released October 2025), the supported options and defaults remain consistent with prior versions, emphasizing modern key types.

Key Files and Storage

Default Locations and Permissions

SSH keys generated by ssh-keygen are stored by default in the user's under a .ssh subdirectory, which is created automatically if it does not exist. The default filenames for private keys include id_rsa for , id_ecdsa for ECDSA, and id_ed25519 for Ed25519, with corresponding public keys appended with .pub, such as id_rsa.pub. These locations ensure that keys are isolated per user for . On the server side, keys for are appended to the ~/.ssh/authorized_keys , where each occupies one line, optionally preceded by space-separated options like from="192.168.1.0/24" to restrict access by or network. This allows multiple keys to be managed centrally for a user account. Strict permissions are enforced to prevent unauthorized access. The .ssh directory must have permissions of 0700 (owner read, write, execute only), private require 0600 (owner read/write only), and the authorized_keys should be 0600 or 0644 but not writable by group or others; sshd will refuse if these are lax unless StrictModes is disabled. Similarly, ssh ignores private keys with overly permissive settings, issuing warnings like "Permissions for 'id_rsa' are too open." On Windows systems using , the default location mirrors systems at %USERPROFILE%\.ssh\, with equivalent strict permissions enforced via ACLs: the .ssh folder accessible only by the user, and private keys readable/writable solely by the owner. Users can override default paths with the -f option in ssh-keygen, specifying a custom filename, but the resulting files must still adhere to the same permission requirements to avoid failures. For client-side host verification, ssh-keygen -H hashes hostnames and addresses in the ~/.ssh/known_hosts file to enhance privacy by obscuring visited hosts, maintaining the default location while applying the same 0600 permissions.

File Formats and Contents

ssh-keygen generates public keys in a compact, single-line ASCII format suitable for use in files like authorized_keys. This format begins with the key type identifier (e.g., "ssh-rsa" for RSA keys or "ssh-ed25519" for Ed25519 keys), followed by a space, then the base64-encoded representation of the public key blob, and optionally ends with a space and a comment such as the user's hostname or email. The public key blob is the binary serialization of the key data in SSH wire format, which for RSA consists of the exponent e and modulus n as multi-precision integers, while for Ed25519 it is simply the 32-byte public point on the curve. This base64 encoding uses the standard alphabet without line breaks, ensuring the entire public key fits on one line. Private keys produced by ssh-keygen can be in two primary formats: the legacy format or the newer format. The format, selected via the -m PEM option, uses base64-encoded DER (Distinguished Encoding Rules) structures wrapped in headers like -----BEGIN [RSA](/page/RSA) PRIVATE KEY----- and -----END [RSA](/page/RSA) PRIVATE KEY-----, compatible with tools like . In contrast, the default format (enabled with -o), introduced in 6.5, begins with -----BEGIN OPENSSH PRIVATE KEY----- and employs a structured layout prefixed by the magic string "openssh-key-v1\0". This format supports multiple keys per file, uses as the key derivation function (PBKDF) for protection with configurable salt and rounds, and encrypts the private key data using in CBC or GCM mode if a is set. Unencrypted private keys use "none" for cipher and KDF, allowing direct access to the contents. The contents of private key files vary by algorithm but include all components necessary for key operations, along with an optional trailing comment. For RSA private keys, both PEM and OpenSSH formats contain the modulus n, public exponent e, private exponent d, prime factors p and q, and the CRT exponents d_p, d_q, and inverse q_inv. ECDSA and Ed25519 private keys include the curve parameters (e.g., "nistp256" for secp256r1), the private scalar or , and the corresponding public key point. Ed25519 specifically uses a 32-byte from which the private scalar is generated. In the OpenSSH format, these are stored as binary blobs within an encrypted or unencrypted list, padded to the cipher block size, and followed by per-key comments. ssh-keygen supports conversion between formats using the -m option, such as exporting to (PKCS#1), , or RFC 4716 (SSH2 public key file format), and importing from compatible sources like or other SSH implementations. For instance, -e -f key.pub -m RFC4716 outputs a multi-line PEM-like structure with headers for . The authorized_keys file, typically located in ~/.ssh/authorized_keys, stores multiple public keys in concatenated single-line format, one per line, for server authentication. Each line may prepend options in the form option=value (e.g., command="script.sh", no-port-forwarding), followed by optional principals, the key type, blob, and comment; blank lines and comments starting with # are ignored. Fingerprints of keys, used for , are computed by ssh-keygen with the -l option on a key file and output as or strings. By default, it uses SHA-256 (per 6594), but can be specified with -E [md5](/page/MD5); for example, ssh-keygen -l -f id_rsa displays 256 SHA256:abc123... user@host ([RSA](/page/RSA)).

Security Considerations

Passphrase Protection

When generating an SSH key pair with ssh-keygen, users are prompted interactively for a to encrypt the private key file, or it can be specified non-interactively using the -N option. An empty can be provided to skip encryption entirely, resulting in an unencrypted private key that remains usable but offers no additional protection beyond file permissions. The passphrase serves as input to a key derivation function (KDF) that generates encryption keys for the private key file. In the traditional (legacy) format, compatible with older OpenSSH versions and specified via the -m PEM option, the private key is encrypted using AES-128-CBC with a simple, single-iteration MD5-based KDF (EVP_BytesToKey) that provides limited resistance to brute-force attacks. In contrast, the newer OpenSSH format—enabled by default since OpenSSH 7.8 in 2018 or explicitly via the -o option—employs AES-256-CBC (or configurable ciphers like the current default aes256-ctr) for encryption, paired with a more robust bcrypt_pbkdf KDF. This KDF incorporates a random 16-byte salt and a configurable number of rounds (default 16, adjustable via the -a flag), where higher rounds exponentially increase computational cost to deter offline attacks; for example, the default equates to approximately 2^{10} bcrypt operations for enhanced security. The derived key is computed as derived_key = bcrypt_pbkdf(passphrase, salt, rounds, key_length, salt_length), providing significantly better protection against dictionary and brute-force attempts compared to the legacy method. Upon attempting to use an encrypted private key, the SSH client (ssh) prompts the user for the passphrase to decrypt it in memory for the authentication session. To avoid repeated entry, the unlocked key can be added to ssh-agent for caching during the session, configurable via the AddKeysToAgent yes directive in ssh_config. Weak passphrases in either format remain susceptible to dictionary attacks, especially in the legacy setup due to its inefficient KDF, potentially allowing recovery of the key if the file is compromised. Omitting a passphrase entirely exposes the private key to immediate use by anyone gaining file access, underscoring the importance of strong passphrase selection despite agent caching conveniences.

Best Practices for Key Management

When generating SSH keys with ssh-keygen, it is recommended to prefer Ed25519 keys due to their strong security properties, compact size, and efficient performance compared to older algorithms. Ed25519 provides equivalent security to a roughly 3000-bit RSA key while resisting certain side-channel attacks that affect other elliptic curve variants. For environments requiring compatibility with legacy systems, use RSA keys of at least 3072 bits, as this size meets current security standards without excessive computational overhead. DSA keys should be avoided entirely, as they are deprecated and no longer supported in modern OpenSSH versions, while ECDSA is supported but inferior to Ed25519 in terms of security margins and resistance to implementation flaws. Key rotation is a critical practice to limit the impact of potential compromises, with recommendations to generate new keys periodically (e.g., annually, based on organizational ) or immediately following any suspected . To rotate, use ssh-keygen with the appropriate type, such as ssh-keygen -t ed25519 -C "new-2025", then distribute the new public key to authorized_keys files on target hosts and revoke old keys by removing them from those files. For FIDO2 hardware keys, revocation can be performed using ssh-keygen -K to manage on the token. This process ensures that access is promptly restricted without disrupting ongoing operations, aligning with NIST guidelines for lifecycle . Regular auditing helps detect weak or unauthorized keys by computing fingerprints with ssh-keygen -l -E sha256 on public key files, which generates a verifiable for comparison against known values. To scan remote hosts for potential weak keys or mismatches, employ ssh-keyscan to collect and verify host fingerprints, ensuring they match expected values stored in known_hosts. These steps facilitate proactive identification of anomalies, such as duplicated or expired keys, as part of routine security hygiene. For secure storage, leverage to cache passphrases in memory, reducing the need for repeated entry while adding keys with a lifetime limit via ssh-add -t 1h to prevent indefinite exposure. Private keys should be backed up in encrypted form and stored offline, such as on , to protect against or compromise. Always maintain strict file permissions (e.g., 600 for private keys) in the default ~/.ssh/ directory. Common pitfalls include accidentally committing private keys to version control repositories, which can expose them to unauthorized access; always use .gitignore rules to exclude id_* files without .pub extensions. Assign unique comments to keys during generation (e.g., via the -C option) to track ownership and purpose, aiding in audits. Once key-based authentication is operational, disable password authentication in sshd_config by setting PasswordAuthentication no and restarting the to eliminate weaker fallback methods. As of 2025, with the release of 10.0, organizations should rotate to configurations supporting post-quantum key exchange algorithms by default, such as those enabled via KexAlgorithms to mitigate "" threats from quantum adversaries. Classical key types like and ECDSA remain vulnerable to quantum attacks, so monitor advisories for emerging post-quantum signing algorithms and plan migrations accordingly.

Advanced Features

FIDO2 and Hardware Key Support

Support for FIDO2 and keys was introduced in 8.2, released in February 2020, enabling the generation of keys backed by FIDO/U2F authenticators such as YubiKeys. These keys use specialized types, including ed25519-sk (based on the Ed25519 algorithm) and ecdsa-sk (using ECDSA over the NIST P-256 curve), which integrate with hardware tokens to perform cryptographic operations without exposing private keys. The -t option in ssh-keygen specifies these types, for example, ssh-keygen -t ed25519-sk prompts the user to insert and touch the device during generation. Key generation for resident keys, which are stored directly on the , employs options like -O [resident](/page/Resident) to persist the key handle on the authenticator and -O verify-required to mandate user verification (such as a PIN or biometric touch) for each signature operation. During the process, ssh-keygen interacts with the attached FIDO2 via libraries like libfido2, generating a pair where the private remains confined to the —never leaving the —and the is extracted for placement in files like authorized_keys. For instance, running ssh-keygen -t ed25519-sk -O [resident](/page/Resident) -O verify-required requires insertion, user touch confirmation, and optional PIN entry, resulting in a private file containing only (the key handle) that is passphrase-protected on disk. Multiple credentials can be enrolled on a single , allowing support for various applications or users. To manage resident keys, the -K option imports them from a specified device path, downloading key handles to the current directory for use with SSH clients; for example, ssh-keygen -K /dev/hidraw0 lists and retrieves available keys. Additional options include -O applications=ssh to set the application ID specifically for SSH, ensuring compatibility with the protocol's credential requirements. The resulting setup enhances by requiring physical interaction, rendering the keys phishing-resistant through bound user verification that ties to the specific . If the device supports PIN protection, no additional is needed on the local key file, simplifying management while maintaining strong safeguards. In 10.0, released on April 9, 2025, improvements include a work-in-progress for verifying FIDO attestation blobs during enrollment (regress/misc/ssh-verify-attestation), providing better logging and validation of authenticity to aid in auditing processes. Additionally, compatibility with hybrid post-quantum algorithms, such as the default mlkem768x25519-sha256, extends to FIDO2 sessions, combining classical methods with quantum-resistant mechanisms for . In 10.2, released on October 10, 2025, ssh-keygen fixes include proper CA signing operations when the CA key is held in a FIDO and improved download of keys from , enhancing reliability for -backed . These enhancements ensure that -backed keys align with evolving cryptographic standards without compromising performance or usability.

Key Inspection and Conversion

ssh-keygen provides several options for inspecting the properties of existing SSH keys without modifying them. The -l option displays key details such as the number of bits, (using SHA256 by default), and key type when given a private or public key file with the -f flag. For example, running ssh-keygen -l -f ~/.ssh/id_rsa outputs the key's size, and SHA256 fingerprints, and random art visualization if (-v) is enabled. This is useful for verifying key strength or matching fingerprints during setup. To extract the public key from a private key file, the -y option reads the private key and prints the corresponding public key to standard output, requiring the -f flag to specify the private key path; for instance, ssh-keygen -y -f ~/.ssh/id_rsa outputs the public key in format. Additionally, the -L option prints the contents of SSH , including validity periods, serial numbers, and principal names, aiding in certificate management and validation. For key , ssh-keygen supports changing and formats using the -p option, which prompts for the old passphrase and a new one while optionally converting the output format via the -m flag (e.g., to or ). The -m option alone specifies formats like RFC4716 (SSH.com format) during generation or conversion, ensuring across different SSH implementations. The -i option imports unencrypted keys in RFC4716 format (including PuTTY's .ppk for keys) and outputs an -compatible version, facilitating migration from tools like . An example export to is ssh-keygen -e -m PKCS8 -f id_rsa.pub, which converts the public key to -encoded format. Supported output formats include , , and OpenSSH proprietary, allowing interoperability with libraries like . Advanced inspection features include the -r option, which generates DNS SSHFP resource records from a public key for a given ; since 10.1 (released October 6, 2025), it produces only SHA256 records by default, with records deprecated and ignored due to security weaknesses. For smartcard keys, the -D option downloads public keys from a or reader, enabling inspection of hardware-stored credentials without . These tools support use cases like verifying key after backups—by recomputing fingerprints—or preparing DNS records for host key verification in automated deployments. However, ssh-keygen has limitations in conversion capabilities; it cannot transform between incompatible key types, such as converting an key to Ed25519, as this would require regenerating the key pair with the desired algorithm. Conversions are restricted to format changes within the same key type and algorithm.

References

  1. [1]
    ssh-keygen(1) - OpenBSD manual pages
    ### Summary of `ssh-keygen` from OpenBSD Man Page
  2. [2]
    Project History - OpenSSH
    OpenSSH is a derivative of the original free ssh 1.2.12 release from Tatu Ylönen. That version was the last one free enough for reuse.Missing: adoption | Show results with:adoption
  3. [3]
    Key-Based Authentication in OpenSSH for Windows - Microsoft Learn
    Oct 3, 2025 · This document provides an overview of how to use these tools on Windows to begin using key-based authentication with Secure Shell (SSH).
  4. [4]
    How to Use ssh-keygen to Generate a New SSH Key?
    Ssh-keygen is a tool for creating new authentication key pairs for SSH, used for automating logins, single sign-on, and authenticating hosts.
  5. [5]
    ssh-keygen(1) - OpenBSD manual pages
    ssh-keygen is an OpenSSH utility that generates, manages, and converts authentication keys for SSH, creating keys for SSH protocol version 2.
  6. [6]
    Manual Pages - OpenSSH
    A file format for public keys is specified in the publickeyfile draft. The command ssh-keygen(1) can be used to convert an OpenSSH public key to this file ...
  7. [7]
    OpenSSH
    OpenSSH is a connectivity tool for remote login using SSH, encrypting traffic to prevent attacks. It provides secure tunneling and authentication.
  8. [8]
    OpenSSH for Windows overview | Microsoft Learn
    Feb 20, 2025 · Beginning with Windows 10 build 1809 and Windows Server 2019, OpenSSH is available as a feature on demand. SSH is based on a client-server ...
  9. [9]
    4.3 Git on the Server - Generating Your SSH Public Key
    You can create them by running a program called ssh-keygen, which is provided with the SSH package on Linux/macOS systems and comes with Git for Windows.
  10. [10]
    SSH History - Part 1 - SSH Communications Security
    After a password-sniffing attack at his university network, Tatu Ylönen designed the first version of the Secure Shell (SSH) protocol. 30 years later, more than ...
  11. [11]
    SSH, The Secure Shell: The Definitive Guide, 2nd Edition - O'Reilly
    History of SSH SSH1 and the SSH-1 protocol were developed in 1995 by Tatu Ylönen, a researcher at the Helsinki University of Technology in Finland.
  12. [12]
    Release Notes - OpenSSH
    OpenSSH 9.9p2 was released on 2025-02-18. It is available from the mirrors listed at https://www.openssh.com/. OpenSSH is a 100% complete SSH protocol 2.0 ...Missing: November | Show results with:November
  13. [13]
    SSH2 vs. SSH1 and why SSH versions still matter - TechTarget
    Jul 27, 2022 · The Secure Shell protocol, SSH, was redesigned and released as SSH2 in 2006. While SSH1 lingers for legacy uses, find out how the protocols differ and why it's ...Missing: timeline | Show results with:timeline
  14. [14]
  15. [15]
    OpenSSH is now Part of Windows! - Anthony Nocentino's Blog
    May 16, 2018 · The OpenSSH client version 7.6p1 is now part of the Windows 10 operating system! Microsoft released Windows 10 Update 1803 and included in that ...
  16. [16]
  17. [17]
    [PDF] NIST Special Publication 800-131A
    Apr 13, 2016 · This document provides guidance for transitioning to stronger cryptographic keys and more robust algorithms, and is for federal agencies.
  18. [18]
    RFC 5656 - Elliptic Curve Algorithm Integration in the Secure Shell ...
    This document describes algorithms based on Elliptic Curve Cryptography (ECC) for use within the Secure Shell (SSH) transport protocol.
  19. [19]
    ssh-keygen(1) - Linux manual page - man7.org
    ssh-keygen will by default write keys in an OpenSSH-specific format. This format is preferred as it offers better protection for keys at rest as well as ...
  20. [20]
    [PDF] High-speed high-security signatures - Ed25519
    Sep 26, 2011 · ... years earlier in Schnorr's original paper [72, Section 2]. Practical use of Schnorr's system was hampered by a patent (which expired in. 2008) ...
  21. [21]
    OpenSSH 8.2 was released
    Feb 14, 2020 · Note: FIDO/U2F tokens are required to implement the ECDSA-P256 "ecdsa-sk" key type, but hardware support for Ed25519 "ed25519-sk" is less common ...
  22. [22]
  23. [23]
    ssh-copy-id(1) - Linux manual page - man7.org
    ssh-copy-id is a script that uses ssh(1) to log into a remote machine (presumably using a login password, so password authentication should be enabled, unless ...
  24. [24]
    OpenSSH 6.5 Released
    * ssh(1), sshd(8): Add support for Ed25519 as a public key type. Ed25519 is a elliptic curve signature scheme that offers better security than ECDSA and DSA and ...<|control11|><|separator|>
  25. [25]
    ssh(1) - OpenBSD manual pages
    ### Summary of SSH Information from OpenBSD Manual
  26. [26]
    sshd(8) - OpenBSD manual pages
    ### Summary on `authorized_keys` File
  27. [27]
    src/usr.bin/ssh/PROTOCOL.key - annotate - HEAD
    ### Summary of OpenSSH Private Key Format (openssh-key-v1)
  28. [28]
    None
    Nothing is retrieved...<|control11|><|separator|>
  29. [29]
  30. [30]
    stronger encryption for SSH keys
    Jul 21, 2013 · After some code reading, it turns out that encryption uses CBC mode, with an IV and algorithm specified in the headers; and the password-to-key ...Why is there a "des-ede3-cbc" in my rsa private key?ssh-keygen: What is the passphrase for?More results from security.stackexchange.comMissing: traditional | Show results with:traditional
  31. [31]
    OpenSSH 7.8 was released
    Aug 24, 2018 · This release includes a number of changes that may affect existing configurations: * ssh-keygen(1): write OpenSSH format private keys by default ...
  32. [32]
    How many KDF rounds for an SSH key?
    Sep 29, 2016 · The default of 16 rounds will perform 1024 rekeying operations in total, which is equal to original bcrypt with a work factor of 10.
  33. [33]
    [PDF] Security of Interactive and Automated Access Management Using ...
    NIST SP 800-131A15 currently provides recommendations ... previously expended on SSH key provisioning, termination, and rotation—and improve operational.
  34. [34]
  35. [35]
    Common SSH Key Risks and How to Prevent Them
    Hardcoded SSH keys pose a serious security risk because they often go unnoticed during audits while silently exposing infrastructure to persistent threats.Missing: fingerprint | Show results with:fingerprint<|separator|>
  36. [36]
    Post-Quantum Cryptography - OpenSSH
    OpenSSH supports a number of cryptographic key agreement algorithms considered to be safe against attacks from quantum computers. We recommend that all SSH ...Missing: ready advisories
  37. [37]
  38. [38]
    Securing SSH with FIDO2 - Yubico Developers
    This guide shows how to generate and use SSH keys directly on your FIDO2 security key with OpenSSH. ... Multiple keys: Use ssh-keygen -K to list resident keys.Missing: enrollment logging hybrid PQ