Skip to content

Instantly share code, notes, and snippets.

@praneeth-katuri
Created May 20, 2025 03:35
Show Gist options
  • Select an option

  • Save praneeth-katuri/c9e92bafb43c56849a130f26afab8d92 to your computer and use it in GitHub Desktop.

Select an option

Save praneeth-katuri/c9e92bafb43c56849a130f26afab8d92 to your computer and use it in GitHub Desktop.
Complete guide to setup Git using SSH on Windows

πŸ›  Complete Guide: Set Up Git with SSH on Windows

βœ… 1. Generate an SSH Key (ED25519 Recommended)

Open PowerShell and run:

ssh-keygen -t ed25519 -C "your_email@example.com"
  • Press Enter to accept the default location: C:\Users\YourName\.ssh\id_ed25519
  • Add a strong passphrase (recommended) or leave blank

βœ… 2. Start the SSH Agent and Add Your Key

Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519

You should see:

Identity added: C:\Users\YourName\.ssh\id_ed25519

βœ… 3. Make ssh-agent Start Automatically on Boot

Set-Service -Name ssh-agent -StartupType Automatic

βœ… 4. Add the SSH Public Key to GitHub (Authentication + Signing)

πŸ“Œ Copy Your Public Key to Clipboard

Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard

πŸ” A. Add as Authorization Key

  1. Go to: https://github.com/settings/ssh
  2. Click "New SSH key"
  3. In the "Title" field, enter: Authentication Key
  4. In the "Key type" dropdown, select: Authentication Key
  5. In the textarea, paste the key using Ctrl + V
  6. Click "Add SSH key"

πŸ–ŠοΈ B. Add as Signing Key

  1. Click "New SSH key" again
  2. Title: Signing Key
  3. Key type: select Signing Key from the dropdown
  4. Paste the same key again using Ctrl + V
  5. Click "Add SSH key"

βœ… 5. Set Up Git to Use SSH Instead of HTTPS

A. When Cloning New Repositories

Use the SSH URL:

git clone git@github.com:your-username/your-repo.git

B. For Existing Repositories

Update the remote URL:

git remote set-url origin git@github.com:your-username/your-repo.git

βœ… 6. Force Git to Use Windows OpenSSH (Fix Passphrase Prompt Issue)

Git for Windows uses its own SSH client by default.

Set Git to use the Windows OpenSSH client:

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

βœ… 7. Test Everything

A. SSH to GitHub

ssh -T git@github.com

Expected output:

Hi your-username! You've successfully authenticated...

βœ… 8. Enable Verified Commit Signing with SSH (Git β‰₯ 2.34)

A. Configure Git to Sign Using SSH Key

git config --global gpg.format ssh
git config --global user.signingkey "$env:USERPROFILE\\.ssh\\id_ed25519.pub"
git config --global commit.gpgsign true

πŸŽ‰ Done

You now have:

  • βœ… SSH access to GitHub (no tokens/passwords)
  • πŸ” Passphrase-free push/pull via ssh-agent
  • 🧾 Verified commits with SSH signing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment