Bitbucket Permission Denied (publickey)
Quick answer
Bitbucket rejected every SSH key your client offered. Find which key is offered with ssh -vvv, then add that public key to your account or point git at the right key.
Most likely fix: See which keys SSH offers
How to fix it
Try these in order — the most common fix is first.
1. See which keys SSH offers
- Run: ssh -vvv -T git@bitbucket.org
- Look for 'Offering public key' and 'Trying private key' lines
- A -1 next to an identity file means it is missing or not a key
- 'Authentication succeeded (publickey)' means it works; 'Shell access is disabled' afterwards is normal
Did this fix it?2. Add your public key to Bitbucket
- Print the key: cat ~/.ssh/id_ed25519.pub
- Open Personal settings > SSH keys > Add key
- Paste the whole line and save
- Retry ssh -T git@bitbucket.org
Did this fix it?3. Force the right key for Bitbucket
- Add a Host bitbucket.org block to ~/.ssh/config with IdentityFile ~/.ssh/<your_key> and IdentitiesOnly yes
- Start the agent and load it: eval $(ssh-agent) then ssh-add ~/.ssh/<your_key>
Did this fix it?4. Fix 'key already registered'
- A key can be linked to only one account; remove it from the other account or generate a new key pair for this one
Did this fix it?
Symptoms
git clone, pull or push over SSH ends with 'Permission denied (publickey)' and 'Could not read from remote repository'.
Why it happens
- The public key is not added to your Bitbucket account
- SSH offers a different key than the one you registered
- The key is registered on another account (a key can belong to only one)
- The key file is malformed or the wrong file was added
- No SSH agent running, so the key is never loaded
This guide also covers
- bitbucket permission denied publickey
- bitbucket could not read from remote repository
- bitbucket ssh key not working
Still not working?
If Bitbucket keeps failing, you're not alone. See every Bitbucket problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to us