Creating a private/public key pair for Tiny Cloud
Instructions on how to generate private/public key pairs for the Tiny Cloud
Contribute to this pageThe 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:
-
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. -
(Optional) Enter a passphrase for accessing the private key.
Important: 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 thessh-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:
- Using Finder, open a Terminal.
-
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. -
(Optional) Enter a passphrase for accessing the private key.
Important: 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 thessh-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:
- Download the Windows package from the Git Downloads page.
- 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. - Click Next on the Information and Select Destination Location screens.
- Select Check daily for Git for Windows updates on the Select Components screen, then click Next.
- Click Next on the remaining screens to accept the default settings.
- Once the installation is complete, click Finish.
Create a private/public key pair on Windows
To create a private/public key pair:
- Open the Start menu (or Windows menu) and open Git Bash.
-
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. -
(Optional) Enter a passphrase for accessing the private key.
Important: 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 thessh-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.
Was this article helpful? Yes - No
Well, that's awkward . Would you mind opening an issue or helping us out?
Thanks for the feedback!
Can't find what you're looking for? Let us know.
Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.