Git: Permission denied (publickey). fatal: Could not read from remote repository.
SSH authentication to GitHub/GitLab/Bitbucket failed — no key, wrong key, or the key isn’t added to your account.
Meaning
The remote uses SSH (git@github.com:…) and the server didn’t accept any key your SSH client offered.
Common causes
- No SSH key generated
- Public key not added to the Git host account
- ssh-agent not running/key not loaded
- Wrong key used (multiple accounts)
- Corporate network blocks port 22
⚡ Quick fix
- Test:
ssh -T git@github.com - Generate a key:
ssh-keygen -t ed25519 -C "you@example.com" - Add
~/.ssh/id_ed25519.pubto your Git host account ssh-add ~/.ssh/id_ed25519- Or switch the remote to HTTPS with a token
Detailed fix by platform
Git
- Debug which key is offered:bash
ssh -vT git@github.com # Port 22 blocked? Use SSH over 443: # ~/.ssh/config Host github.com Hostname ssh.github.com Port 443 User git
How to diagnose
- Remote — SSH or HTTPS URL?
- Key — Which key does ssh -v offer?
- Account — Is that key added?
- Network — Port 22 reachable?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026