Git / Git
Git permission denied (publickey)
Fix Git SSH permission denied publickey errors when cloning, pulling, or pushing repositories.
- Category
- Git
- Error signature
Permission denied (publickey).- Quick fix
- Add the correct SSH key to your agent and Git hosting account, then test the SSH connection.
- Updated
What this error means
Permission denied (publickey) means Git attempted SSH authentication, but the remote host did not accept any public key offered by your machine.
Common causes
- No SSH key exists on the machine.
- The key exists locally but is not loaded into
ssh-agent. - The matching public key was not added to GitHub, GitLab, Bitbucket, or your internal Git host.
- Multiple keys exist and SSH is offering the wrong one.
Quick fixes
-
Check for an existing key:
ls ~/.ssh -
Add the key to your SSH agent:
ssh-add ~/.ssh/id_ed25519 -
Test the host connection:
ssh -T git@github.com -
Confirm the repository remote uses the expected URL:
git remote -v
Step-by-step troubleshooting
- Run
ssh -vT git@github.comor the equivalent host command to see which keys are offered. - Add the public key from
~/.ssh/id_ed25519.pubto your Git hosting account. - If you use multiple accounts, create or update
~/.ssh/configwith a host-specificIdentityFile. - Verify repository access permissions on the remote host.
- Retry
git clone,git pull, orgit push.
Related errors
fatal: Could not read from remote repositoryHost key verification failedRepository not found
FAQ
Can I switch to HTTPS instead?
Yes. Update the remote URL to HTTPS if your workflow uses personal access tokens instead of SSH keys.
Does this mean the repository does not exist?
Not necessarily. Private repositories can look unreachable when authentication fails.
Which key type should I create today?
Use an Ed25519 key unless your environment requires a different SSH key type.