Skip to main content

Create SSH Key Pairs in Your Browser Generate RSA and ECDSA key pairs for SSH authentication.

SSH Key Generator illustration
🔐

SSH Key Generator

Generate RSA and ECDSA key pairs for SSH authentication.

1

Select Type

RSA or ECDSA.

2

Configure

Key size.

3

Generate

Create key pair.

Loading tool...

What Is SSH Key Generator?

A SSH Key Generator is a tool that generates secure ssh key pairs, enabling users to authenticate with servers without needing passwords. Developers and system administrators use it to manage access to their systems, solving the problem of securely granting access to multiple users or services. One specific issue it addresses is the need for a convenient way to generate rsa key pairs and ecdsa keys in a secure manner.

The SSH Key Generator tool allows users to choose between RSA and ECDSA key types, with RSA supporting 2048 and 4096 bit sizes. This flexibility enables users to select the most suitable encryption method for their specific use case. It also exports keys in PEM format, making it easy to integrate with existing systems that rely on this standard.

What makes this tool different is its ability to generate ssh key pairs directly in the browser using the Web Crypto API, ensuring private keys never leave the user's device. The generated public and private keys are displayed in a readable format, allowing users to easily copy them for use in their applications or systems. This approach simplifies the process of generating an rsa key pair or ecdsa key, making it more accessible to developers who need to manage ssh access securely. It essentially serves as an alternative to traditional ssh keygen tools, providing a convenient and secure way to generate ssh keys.

Why Use SSH Key Generator?

  • RSA and ECDSA
  • Configurable sizes
  • PEM export
  • 100% client-side

Common Use Cases

Server Access

SSH auth.

Git

GitHub/GitLab SSH.

Development

Dev keys.

Education

Public-key crypto.

Technical Guide

The tool uses the Web Crypto API to generate secure ssh key pairs directly in the browser. Specifically, it utilizes the `crypto.subtle.generateKey()` method to create RSA and ECDSA keys. For RSA, it employs the RSASSA-PKCS1-v1_5 algorithm with a SHA-256 hash function, while for ECDSA, it uses the P-256 curve. The generated keys are then exported in SPKI (Subject Public Key Information) format for public keys and PKCS#8 format for private keys using `crypto.subtle.exportKey()`. This process ensures that private keys remain secure and never leave the user's browser.

Under the hood, the tool relies on React state management to handle key generation and storage. It uses `useState` hooks to maintain the current key type, size, and generated public and private keys. The `useCallback` hook is used to memoize functions that generate keys and copy them to the clipboard. When generating keys, it converts the resulting ArrayBuffer to a base64-encoded string using the `ab2b64()` function, which is then formatted into PEM (Privacy-Enhanced Mail) format using the `fmtPem()` function.

The tool's key generation process involves creating an instance of the Web Crypto API's `generateKey` method, passing in the desired algorithm and key size. For RSA keys, this includes specifying a modulus length of 2048 or 4096 bits, as well as a public exponent of 65537 (0x10001). The resulting key pair is then exported using the `exportKey` method, which returns an ArrayBuffer containing the encoded key data. This data is subsequently converted to PEM format and displayed in a textarea for easy copying.

In terms of security, the tool's use of the Web Crypto API ensures that all key generation and storage occurs within the browser, minimizing the risk of private key exposure. The generated keys are also formatted according to standard PEM conventions, making it easy to integrate them with existing systems that rely on this format. By leveraging established cryptographic algorithms like RSASSA-PKCS1-v1_5 and ECDSA, the tool provides a secure means of generating ssh key pairs for authentication purposes.

The `fmtPem()` function plays a crucial role in formatting the generated keys into PEM format. It takes two arguments: the base64-encoded key data and the type of key being formatted (either "PUBLIC KEY" or "EC PRIVATE KEY"). The function splits the key data into 64-character chunks, joining them with newline characters to create the final PEM-formatted string. This formatting is essential for ensuring compatibility with existing systems that rely on PEM-encoded keys.

The tool's clipboard functionality is handled by the `copyToClipboard()` function, which takes a string argument representing the text to be copied. It uses the browser's built-in `navigator.clipboard` API to write the provided text to the system clipboard. The function returns a boolean value indicating whether the copy operation was successful, allowing the tool to display a confirmation message or error notification as needed.

The React library is used extensively throughout the tool, providing a framework for building and managing the user interface. Specifically, it uses React's `useState` hook to maintain state variables like key type, size, and generated keys. The `useCallback` hook is also employed to memoize functions that handle key generation and clipboard operations.

The use of specific technologies like Web Crypto API, React, and PEM formatting enables the tool to provide a secure means of generating ssh key pairs directly in the browser. By leveraging these established standards and libraries, it simplifies the process of managing access to systems while minimizing security risks associated with private key exposure.

Tips & Best Practices

  • 1
    Select RSA for larger key sizes, up to 4096 bits
  • 2
    Choose ECDSA for smaller key sizes and faster generation
  • 3
    Click Generate Key Pair to start the generation process
  • 4
    Use the Copy button to copy public or private keys to clipboard
  • 5
    Verify generated keys are in PEM format, starting with -----BEGIN
  • 6
    Check browser support for Web Crypto API before generating keys

Related Tools

Frequently Asked Questions

Q Is this SSH key generator free?
Yes. It is free to use with no signup required.
Q Is it secure?
It uses the Web Crypto API to generate keys in your browser. Private keys never leave your device.
Q Does it work on mobile?
Yes, it works on mobile devices with browsers that support Web Crypto API.
Q What browsers are supported?
All modern browsers that support the Web Crypto API, including Chrome, Firefox, Safari, and Edge.
Q Can I add a passphrase?
For passphrase protection, use ssh-keygen locally. This tool exports keys in PEM format without passphrase support.

About This Tool

SSH Key Generator is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.