git auth_error ai_generated true

Permission denied (publickey). fatal: Could not read from remote repository.

ID: git/permission-denied-publickey

Also available as: JSON · Markdown
88%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

SSH key not configured or not added to SSH agent.

generic

Workarounds

  1. 92% success Add SSH key to agent and verify: ssh-add, then ssh -T [email protected]
    eval $(ssh-agent) && ssh-add ~/.ssh/id_ed25519 && ssh -T [email protected]

    Sources: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection

  2. 88% success Use HTTPS with personal access token or gh auth login
    Use HTTPS with personal access token or gh auth login

    Sources: https://cli.github.com/manual/gh_auth_login

Dead Ends

Common approaches that don't work:

  1. Switch to HTTPS and enter password every time 70% fail

    Tedious, and GitHub disabled password auth in 2021

  2. Generate new key pair every time 60% fail

    Doesn't help if the key isn't added to GitHub/agent

Error Chain

Frequently confused with: