Server Management

Creating an SSH Key Using ssh-keygen

Last modified 8/22/2023

SSH  keys are used for secure authentication and communication between systems. They provide a secure and convenient way to log into remote servers or transfer files between systems over a network. The ssh-keygen tool is a utility for generating and managing SSH key pairs.

Create an SSH Key Pair

Follow these steps to generate an SSH key pair using the ssh-keygen command:

  1. Open a terminal on Linux or a Powershell console on Windows on your local machine.

  2. In the terminal, type the following command to generate an SSH key pair:
    ssh-keygen -t rsa -b 4096 -C "your_comment_here"

    1. -t rsa: Specifies the type of key to create (RSA).
    2. -b 4096: Specifies the number of bits in the key (higher bits provide stronger security).
    3. -C "your_comment_here": Provides a comment or label for the key, usually your email address or hostname.

  3. The command will prompt you to choose where to save the generated key pair. The default location on Linux is usually ~/.ssh/id_rsa for the private key and ~/.ssh/id_rsa.pub for the public key and on Windows it is C:\Users\username\.ssh\id_rsa for the private key and  C:\Users\username\.ssh\id_rsa.pub for the public key. Press Enter to accept the default location or provide a different one.

  4. You will be prompted to set a passphrase for the key. A passphrase adds an extra layer of security to your private key. If someone gains access to your private key, they would still need the passphrase to use it.

  5. The tool will now generate your key pair.

Using your SSH Key Pair

Once created, you can now use your SSH key for authentication on servers where you have your public key configured. For example, you can copy the contents of your public key (id_rsa.pub) and add it to the ~/.ssh/authorized_keys file on remote servers where you want to log in.

To configure your key pair on servers provided by Tech Solutions, please send your public key via Sendto to a member of the CCA team.