How do you generate an SSH key pair?

0113

To generate an SSH key pair, you can use the ssh-keygen command. Here’s how to do it:

  1. Open your terminal.

  2. Run the following command:

    ssh-keygen -t rsa -b 4096

    This command specifies:

    • -t rsa: Use the RSA algorithm for key generation.
    • -b 4096: Create a key with 4096 bits for strong security.
  3. When prompted, you can:

    • Enter a file path to save the key (press Enter to accept the default path ~/.ssh/id_rsa).
    • Enter a passphrase (you can leave this empty by pressing Enter twice).

After running the command, you will see output indicating that your keys have been generated. The private key will be saved in the specified file (e.g., ~/.ssh/id_rsa), and the public key will be saved in the same location with a .pub extension (e.g., ~/.ssh/id_rsa.pub).

To view your public key, you can use:

cat ~/.ssh/id_rsa.pub

This will display your public key, which you can share with remote servers for authentication.

0 Comments

no data
Be the first to share your comment!