Git Permission Denied Publickey Fix

Git publickey errors mean SSH authentication failed before repository permissions could be used.

Symptoms

  • git pull or git clone returns Permission denied publickey.
  • HTTPS remote works but SSH remote fails.
  • CI or deployment server cannot fetch a private repository.

Likely causes

  • No SSH key is loaded in ssh-agent.
  • The remote URL points to the wrong host or account.
  • The key is not added to the Git provider.
  • Deploy key lacks access to the target repository.

Fix steps

  1. Check git remote -v.
  2. Run ssh -T against the Git host.
  3. Load the correct key into ssh-agent.
  4. Add a deploy key or machine user with the required repository access.

Verify the fix

  • Run ssh -vT for detailed key selection logs.
  • Clone a small private test repo if available.
  • Confirm CI secrets are mounted in the job that runs Git.

FAQ

Is this a Git branch problem?

No. SSH authentication fails before Git can inspect branches.

Can one key access multiple repos?

Yes when the provider account or deploy-key settings allow it.

Related tools and guides

Last updated: May 18, 2026