How to generate a new SSH key pair in linux

Jun 23, 2023ยท

1 min read

Play this article
  1. Open a terminal.

  2. Type the following command and press Enter:

     ssh-keygen -t rsa -b 4096
    

    This command generates a new RSA SSH key pair with a key length of 4096 bits.

  3. You will be prompted to choose a location to save the key pair. Press Enter to accept the default location (~/.ssh/id_rsa).

  4. You will be prompted to enter a passphrase for the key pair. It is recommended to provide a passphrase for added security, but you can also leave it blank by pressing Enter.

  5. Once the key pair is generated, you can display the public key by :

     cat ~/.ssh/id_rsa.pub
    

    The output will be your newly generated public SSH key.

Remember, the public key is safe to share with others or use for authentication, while the private key (typically id_rsa) should be kept secure and not shared with anyone.

ย