Skip to content

Instantly share code, notes, and snippets.

@flandersen
Forked from praneeth-katuri/git-ssh-setup-windows.md
Last active November 21, 2025 16:07
Show Gist options
  • Select an option

  • Save flandersen/78100ad12cd9c5790a91f37eba757868 to your computer and use it in GitHub Desktop.

Select an option

Save flandersen/78100ad12cd9c5790a91f37eba757868 to your computer and use it in GitHub Desktop.
Complete guide to setup Git using SSH on Windows for Bitbucket

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

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

Open PowerShell and run:

ssh-keygen -t ed25519 -C "your_email@example.com" -f "C:\Users\YourName\.ssh\some_service_key"
  • Press Enter to accept the default location: C:\Users\YourName\.ssh\some_service_key
  • 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\some_service_key

You should see:

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

βœ… 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\some_ssh_key.pub | Set-Clipboard

πŸ” A. Add as Authorization Key (Bitbucket)

  1. Go to the Bitbucket-Server.
  2. Manage account
  3. "SSH-Keys"
  4. Click "Add key"
  5. In the "Key" text area, paste the key using Ctrl + V
  6. Enter a key label.
  7. Define the expiration time.
  8. Click "Save"

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

A. When Cloning New Repositories

Use the SSH URL:

git clone git@bitbucket.arpa:project-name/your-repo.git

B. For Existing Repositories

Update the remote URL:

git remote set-url origin git@bitbucket.arpa:project-name/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