Creating a private/public key pair for Tiny Cloud

The procedure for creating a key pair depends on the operating system of the host machine.

Linux

To create a private/public key pair on a Linux operating system:

Installing OpenSSL on Linux

The procedure for installing OpenSSL on Linux distributions varies. The installation commands for common Linux distributions have been provided here.

Red Hat Enterprise Linux 7 or CentOS 7

On a command line, run the following commands to install OpenSSL on:

  • Red Hat Enterprise Linux 6 or 7.

  • CentOS 6 or 7.

sudo yum check-update
sudo yum install openssl

Red Hat Enterprise Linux 8+, Fedora, or CentOS 8+

On a command line, run the following commands to install OpenSSL on:

  • Red Hat Enterprise Linux 8 or later.

  • CentOS 8 or later.

  • Fedora 18 or later.

sudo dnf check-update
sudo dnf install openssl

Debian, Ubuntu, Linux Mint, or other Debian-based distributions

On a command line, run the following commands to install OpenSSL on Debian-based operating systems (such as: Debian, Ubuntu, and Linux Mint).

sudo apt update
sudo apt install openssl

SUSE Linux Enterprise Server or openSUSE

On a command line, run the following commands to install OpenSSL on openSUSE-based operating systems (such as: openSUSE and SUSE Linux Enterprise Server).

sudo zypper refresh
sudo zypper install openssl

Create a private/public key pair on Linux

To create a private/public key pair:

  1. On a command line, run:

     ssh-keygen -m PEM -t rsa -b 2048 -f <MY_KEY_PAIR_NAME>

    Where `<MY_KEY_PAIR_NAME>` should be replaced with a name for the key pair.

  2. (Optional) Enter a passphrase for accessing the private key.

    Some libraries used for generating JWTs do not support private keys encrypted with a passphrase. When passphrases are not supported, leave the passphrase blank or include -N "" option for the ssh-keygen command.

Two files will be created in the current directory:

  • <MY_KEY_PAIR_NAME> - The private key.

  • <MY_KEY_PAIR_NAME>.pub - The public key.

Retrieve the public key on Linux

To retrieve the public key, on a command line, run:

openssl rsa -in <MY_KEY_PAIR_NAME> -outform DER -pubout | base64 -w0

The public key for the <MY_KEY_PAIR_NAME> key pair will be printed on the command line with base64 encoding.

Apple macOS

To create a private/public key pair on a macOS operating system:

Create a private/public key pair on macOS

To create a private/public key pair:

  1. Using Finder, open a Terminal.

  2. On a terminal, run:

     ssh-keygen -m PEM -t rsa -b 2048 -f <MY_KEY_PAIR_NAME>

    Where `<MY_KEY_PAIR_NAME>` should be replaced with a name for the key pair.

  3. (Optional) Enter a passphrase for accessing the private key.

    Some libraries used for generating JWTs do not support private keys encrypted with a passphrase. When passphrases are not supported, leave the passphrase blank or include -N "" option for the ssh-keygen command.

Two files will be created in the current directory:

  • <MY_KEY_PAIR_NAME> - The private key.

  • <MY_KEY_PAIR_NAME>.pub - The public key.

Retrieve the public key on macOS

To retrieve the public key, on a terminal, run:

openssl rsa -in <MY_KEY_PAIR_NAME> -outform DER -pubout | base64 -

The public key for the <MY_KEY_PAIR_NAME> key pair will be printed on the terminal with base64 encoding.

Microsoft Windows

To create a private/public key pair on a Microsoft Windows operating system:

Installing OpenSSL on Microsoft Windows

To install OpenSSL with Git for Windows:

  1. Download the Windows package from the Git Downloads page.

  2. Open the downloaded file Git-<VERSION>-<ARCH>-bit.exe, where `<VERSION>` is the latest version of Git for Windows and `<ARCH>` is the architecture, such as 32-bit or 64-bit.

  3. Click Next on the Information and Select Destination Location screens.

  4. Select Check daily for Git for Windows updates on the Select Components screen, then click Next.

  5. Click Next on the remaining screens to accept the default settings.

  6. Once the installation is complete, click Finish.

Create a private/public key pair on Windows

To create a private/public key pair:

  1. Open the Start menu (or Windows menu) and open Git Bash.

  2. On the Git bash command line, run:

     ssh-keygen -m PEM -t rsa -b 2048 -f <MY_KEY_PAIR_NAME>

    Where `<MY_KEY_PAIR_NAME>` should be replaced with a name for the key pair.

  3. (Optional) Enter a passphrase for accessing the private key.

    Some libraries used for generating JWTs do not support private keys encrypted with a passphrase. When passphrases are not supported, leave the passphrase blank or include -N "" option for the ssh-keygen command.

Two files will be created in the current directory:

  • <MY_KEY_PAIR_NAME> - The private key.

  • <MY_KEY_PAIR_NAME>.pub - The public key.

Retrieve the public key on Windows

To retrieve the public key, on a Git bash command line, run:

openssl rsa -in <MY_KEY_PAIR_NAME> -outform DER -pubout | base64 -w0

The public key for the <MY_KEY_PAIR_NAME> key pair will be printed on the command line with base64 encoding.