Git Permission Denied (Publickey) — SSH Authentication Failure on Windows
Warningapplication
Overview
Fix Git 'Permission denied (publickey)' error on Windows when SSH key authentication fails for GitHub, GitLab, or Bitbucket repositories.
Key Details
- This error occurs when Git cannot authenticate with the remote server using SSH keys
- Windows has multiple SSH agents: OpenSSH (built-in), Git for Windows SSH, and PuTTY (Pageant)
- SSH keys must be added to both the local SSH agent and the remote service (GitHub/GitLab/Bitbucket)
- Windows OpenSSH stores keys in %USERPROFILE%\.ssh\ directory
- The wrong SSH client or agent being used is a common Windows-specific issue
Common Causes
- SSH key not added to the GitHub/GitLab/Bitbucket account settings
- SSH agent not running or key not loaded into the agent
- Git using a different SSH client than where the keys are configured
- SSH key passphrase not entered or cached, causing silent authentication failure
Steps
- 1Test SSH connection: 'ssh -T git@github.com' — should show your username if working
- 2Generate SSH key if none exists: 'ssh-keygen -t ed25519 -C "your@email.com"'
- 3Start SSH agent: open PowerShell as admin > 'Get-Service ssh-agent | Set-Service -StartupType Automatic' > 'Start-Service ssh-agent'
- 4Add key to agent: 'ssh-add %USERPROFILE%\.ssh\id_ed25519'
- 5Add the public key to GitHub: copy output of 'type %USERPROFILE%\.ssh\id_ed25519.pub' > GitHub > Settings > SSH and GPG keys > New SSH key
Tags
gitsshpublickeyauthenticationgithub
Related Items
More in Application
windows-C0000005-access-violationWindows Error 0xC0000005 — Access Violation
Errorwindows-C000007B-bad-image-formatWindows Error 0xC000007B — Bad Image Format
Errorwindows-C0000142-application-init-failedWindows Error 0xC0000142 — Application Init Failed
Errorwindows-SxS-Error-side-by-side-configuration-errorWindows Error SxS-Error — Side-by-Side Configuration Error
Warningwindows-DLL-Missing-dll-not-foundWindows Error DLL-Missing — DLL Not Found
Warningwindows-app-runtime-r6025Windows Runtime Error R6025 — Pure Virtual Function Call
WarningFrequently Asked Questions
SSH is more convenient once set up — no password prompts. HTTPS works immediately but requires a credential manager for password caching. GitHub recommends SSH with ed25519 keys.