askvity

How do I find my private SSH key?

Published in SSH Keys 2 mins read

Here's how to locate your private SSH key on macOS or Linux:

Steps to Find Your Private SSH Key

  1. Open Terminal: Launch the Terminal application on your macOS or Linux system. According to the reference, whether you use macOS or Linux, you can open your Terminal application to start.

  2. Navigate to the .ssh directory: In the Terminal, type the following command and press Enter:

    cd ~/.ssh/
  3. List files: If the .ssh folder exists, use the ls command to list the files within it:

    ls
  4. Identify key pair: Look for a pair of files with similar names. The private key will typically be named id_ed25519 or id_rsa (without any extension). The corresponding public key will have the same name but with a .pub extension (e.g., id_ed25519.pub or id_rsa.pub). The reference suggests that id_ed25519 and id_ed25519.pub are preferable, but id_rsa and id_rsa.pub are also acceptable.

    File Name Key Type
    id_ed25519 Private
    id_ed25519.pub Public
    id_rsa Private
    id_rsa.pub Public

Important: Your private key (e.g., id_ed25519 or id_rsa) is sensitive. Treat it with extreme care and avoid sharing it with anyone. Your public key (e.g., id_ed25519.pub or id_rsa.pub) is safe to share.

Related Articles