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.
Permission denied (publickey)Could not read from remote repositoryPlease make sure you have the correct access rights 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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Git
- Git SSL certificate problem fatal: unable to access 'https://…': SSL certificate problem: unable to get local issuer certificate
- rebase in progress fatal: It seems that there is already a rebase-merge directory, and I wonder if you are in the middle of another rebase.
- unfinished merge fatal: You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you merge.
Other ways to find it
Where this error sits
Origin: Build & delivery. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 12 Oct 2026