Generating SSH Key Pair on Linux

Last Updated : Nov 20, 2024 |
Prolog information
This topic gives instructions on how to generate SSH key pair on Linux along with an example.
Before you begin
  • You must enable SSH public key authentication.
  1. Use ssh-keygen command to generate key pair.
    ADDITIONAL INFORMATION:
    The filename (-f) and comment (-C) options should be used to specify useful information about the key files.
    ADDITIONAL INFORMATION:
    ssh-keygen -t rsa-sha2-512 -b 2048 -f bgw1-root-key -C bgw1-root-rsa-sha2-512-2048
  2. Do one of the following:
    1. To generate a private key using password, enter the password which is associated with the private key and again enter the password for confirmation.
    2. To generate a private key without using password, press Enter button twice.
Result
The process generates the key pair.
bgw1-root-key is for Private key.
bgw1-root-key.pub is for Public key.