Follow these steps to generate and use SSH keys on Windows for secure access to remote servers and services like GitHub, GitLab, or your own SSH server.


βœ… Prerequisites

  • Windows 10 or later
  • Access to Command Prompt or PowerShell
  • Git for Windows (includes ssh and ssh-keygen)

1. 🧰 Generate a New SSH Key

Open your terminal and run:

ssh-keygen -t ed25519 -C "[email protected]"

If your system doesn’t support ed25519, use:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

When prompted:

  • Save location: Press Enter to accept the default (C:\Users\<YourUser>\.ssh\id_ed25519)
  • Passphrase (optional but recommended): Enter a secure passphrase

2. πŸ”‘ Add Your SSH Key to the Agent

Start the SSH agent

eval $(ssh-agent -s)

Add your private key to the agent:

ssh-add ~/.ssh/id_ed25519

πŸ’‘ Replace id_ed25519 with your key file if you named it differently.


3. πŸ“‹ Add Your Public Key to the Remote Server

Copy your public key to clipboard:

clip < ~/.ssh/id_ed25519.pub

Then, add it to:


4. πŸ§ͺ Test Your Connection

Test the connection:

ssh -T [email protected]

If successful, you’ll see a welcome message:

Hi username! You’ve successfully authenticated.