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

Quick fixes

  1. Check for an existing key:

    ls ~/.ssh
  2. Add the key to your SSH agent:

    ssh-add ~/.ssh/id_ed25519
  3. Test the host connection:

    ssh -T git@github.com
  4. 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.

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.