SSH Key Pair Generation Guide
USP uses SSH key pairs for authentication in multiple parts of its configuration. This guide explains how to generate an SSH key pair using ssh-keygen, and can be applied to any context.
For a deeper explanation of how SSH keys are used in USP and where they appear in the configuration, refer to Keys.
For the two key pairs required to establish secure tunnels between USP Clients and USP Servers, refer to the USP Tunnel SSH Keys Generation Guide.
Prerequisites
ssh-keygenis part of OpenSSH. On Linux, it is typically installed by default. On Windows, the OpenSSH Client must be installed. It is not installed by default on Windows Server 2016 and may need to be installed separately. The Windows commands in this guide are written for CMD and also run unchanged in Windows PowerShell 5.1 and PowerShell 7.x.- Define the absolute path of the directory where you will store the keys. This guide refers to it as
.<ssh-keys-directory>
Generating an SSH Key Pair
SSH key pairs consist of:
- A private key, which must be kept secure.
- A public key, which is shared with remote systems for authentication.
To generate a key pair using the ssh-keygen tool:
1. Create a Directory for Your Keys
Create a directory to keep all your key files in one location:
- Linux
- Windows (CMD)
mkdir -p <ssh-keys-directory>
mkdir <ssh-keys-directory>
2. Generate a New SSH Key Pair
- Linux
- Windows (CMD)
ssh-keygen \
-t rsa \
-b 2048 \
-m PEM \
-f <ssh-keys-directory>/my_ssh_key
ssh-keygen -t rsa -b 2048 -m PEM -f <ssh-keys-directory>\my_ssh_key
When ssh-keygen prompts for a passphrase, press Enter twice to leave it empty. USP cannot use passphrase-protected private keys.
The command uses the following options:
-t rsa: Generates an RSA key.-b 2048: Uses a 2048-bit key length.-m PEM: Exports the private key in PEM format (required for USP).-f: Specifies the output filename (no extension).
The command produces the following files:
my_ssh_key: the private key (PEM format)my_ssh_key.pub: the corresponding public key (OpenSSH format)
Repeat this process as needed for any additional key pairs you require.
Working with Key Files
To use a key, you typically need to copy its content into a configuration field or place the file where a component can read it.
Viewing a Key File
To display the content of a key file so you can copy and paste it, run:
- Linux
- Windows (CMD)
cat <ssh-keys-directory>/<key-file>
type <ssh-keys-directory>\<key-file>
Replace <key-file> with the name of the private or public key file (for example, my_ssh_key or my_ssh_key.pub).
Moving a Key File
To move a key file to another directory, run:
- Linux
- Windows (CMD)
mv <ssh-keys-directory>/<key-file> <destination-directory>/
move <ssh-keys-directory>\<key-file> <destination-directory>\
Replace <key-file> with the name of the private or public key file (for example, my_ssh_key or my_ssh_key.pub), and <destination-directory> with the directory to move the key file to.