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

  1. Check for an existing key:
   ls ~/.ssh
  1. Add the key to your SSH agent:
   ssh-add ~/.ssh/id_ed25519
  1. Test the host connection:
   ssh -T git@github.com
  1. Confirm the repository remote uses the expected URL:
   git remote -v

Step-by-step troubleshooting

  1. Run ssh -vT git@github.com or the equivalent host command to see which keys are offered.
  2. Add the public key from ~/.ssh/id_ed25519.pub to your Git hosting account.
  3. If you use multiple accounts, create or update ~/.ssh/config with a host-specific IdentityFile.
  4. Verify repository access permissions on the remote host.
  5. Retry git clone, git pull, or git push.