---
title: Create an RSA or SSH key pair
description: Learn how to create an RSA or SSH key pair
---

Generating an RSA key pair is essential for encrypting and decrypting sensitive data securely. This guide provides step-by-step instructions for generating an RSA key pair using the command line.

## Creating an RSA keypair
[OpenSSL](https://www.openssl.org/) is a widely-used toolkit for the TLS and SSL protocols. It can also be used to generate RSA key pairs.

### Creating an RSA key pair on the command line using OpenSSL
1. Generate the Private Key:

    ```bash
    openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
    ```

2. Extract the Public Key:

    ```bash
    openssl rsa -pubout -in private_key.pem -out public_key.pem
    ```

3. View the Private Key:

    ```bash
    cat private_key.pem
    ```

4. View the Public Key:

    ```bash
    cat public_key.pem
    ```

## Creating an SSH keypair
[ssh-keygen](https://www.ssh.com/academy/ssh/keygen) is a tool for creating new authentication key pairs for SSH.
Such key pairs are used for automating logins, single sign-on, and for authenticating hosts.

### Creating an SSH key pair in Linux or macOS using `ssh-keygen`
1. Generate the key pair:

    ```bash
    ssh-keygen -t rsa -b 4096 -f figure_identity
    ```

2. View the Public key for pasting:

    ```bash
    cat figure_identity.pub
    ```

### Creating an SSH key pair in Windows using `PuTTygen`
1. Download PuTTy Key Generator [PuTTygen.exe](https://www.chiark.greenend.org.uk/%7Esgtatham/putty/latest.html) file and run it.
2. In the **Key** menu, select **SSH-2 RSA** Key
3. In **Parameters**, select the **RSA** option.
4. In Number of bits in generated key field, enter 4096
5. In **Actions**, select **Generate**
6. In the blank area under the progress bar, move your pointer in a random pattern to complete key pair generation.
7. When generation completes, copy the contents of the Public key for pasting
