Skip to content

Instantly share code, notes, and snippets.

@deltoss
Last active June 18, 2025 00:58
Show Gist options
  • Save deltoss/d7aa8beb0e6d456b223041f9fe120b61 to your computer and use it in GitHub Desktop.
Save deltoss/d7aa8beb0e6d456b223041f9fe120b61 to your computer and use it in GitHub Desktop.
How to set up SSH keys on a Windows machine.

SSH on Windows

πŸ”‘ Generating SSH Keys with OpenSSH

  1. Open a terminal in the directory where you want to save your key.

  2. Run this command to generate a new SSH key:

    ssh-keygen -t ed25519 -C "Your Key Name"

    For older systems that don't support Ed25519, use RSA instead:

    ssh-keygen -t rsa -b 4096 -C "Your Key Name"
  3. Follow the prompts. Once done, you'll have both a private and public key saved. Copy the contents of the .pub file to your VCS (Version Control System) service of choice.

    See below links for your service:

  4. To SSH into a server using your key:

    ssh -i "<PathToPrivateKeyFile>" <username>@<ServerIpAddress>

πŸš€ Auto-Loading Keys with OpenSSH Authentication Agent

  1. Open a terminal as Administrator in the directory where your key is stored.

  2. Start the OpenSSH agent and set it to launch automatically:

    Start-Service ssh-agent
    Set-Service -Name ssh-agent -StartupType Automatic
  3. Add your private key to the agent:

    ssh-add ./YourPrivateKey
  4. Make Git explicitly use OpenSSH:

    git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe

πŸ’‘ Tip

Want other ways to auto-load SSH keys? Check out this helpful post: Server Fault - Does ssh autoload everything in .ssh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment