SSH keys are an essential tool for securely accessing remote servers and systems. They provide a secure method for authentication and eliminate the need for passwords. This guide walks you through the process of generating SSH keys.
What Are SSH Keys?
SSH keys are a pair of cryptographic keys used for secure communication between a client and a server. The pair consists of:
- Private Key: Stored securely on your device and never shared.
- Public Key: Shared with the server to grant access.
Steps to Generate SSH Keys
1. Open a Terminal or Command Prompt
- On Linux or macOS: Open your terminal.
- On Windows: Press the Windows key or open up the Start Menu. Type “cmd” and then click “Command Prompt”.
2. Use the ssh-keygen Command
Run the following command to generate a new SSH key pair:
ssh-keygen
3. Specify the Key Save Location
You will be prompted to specify the location to save the key pair:
Enter file in which to save the key (/home/user/.ssh/id_rsa):- Press Enter to save it to the default location (
~/.ssh/id_rsa). - If you want a custom location, specify the file path and press Enter.
4. Set a Passphrase (Optional)
You will be asked to create a passphrase to secure the private key:
Enter passphrase (empty for no passphrase):- Enter a passphrase for added security or press Enter to leave it empty.
5. Verify Key Generation
Once completed, you will see output similar to:
Your identification has been saved in /home/user/.ssh/id_rsa
Your public key has been saved in /home/user/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:examplefingerprint your_email@example.com