DevFixes
HomeGitAuthentication
GitHubIntermediateHigh severity

git@github.com: Permission denied (publickey)

GitHub rejected the SSH connection because no uploaded SSH key matched a key offered by your computer.

5-15 min Popularity 96/100 Verified 2026-07-21
Debug with AI

What does this error mean?

Git reached GitHub over SSH, but GitHub could not associate any key offered by your SSH client with an account that can access the repository.

Why does this happen?

  • No SSH key exists on this computer.
  • The SSH key exists but is not loaded into the SSH agent.
  • The public key has not been added to the correct GitHub account.
  • The remote points to a GitHub account or organization you cannot access.
  • An SSH config rule is offering the wrong key for github.com.

AI explanation

Plain-English analysis

The repository is not rejecting your Git command itself. The connection fails one layer earlier, during SSH identity verification. First confirm which remote host Git uses, then inspect which keys the SSH client offers, and finally verify that the matching public key belongs to a GitHub account with repository access.

Quick fix

Terminal
ssh -T git@github.com
ssh-add -l
git remote -v
Expected output: GitHub reports successful authentication, the SSH agent lists a key, and the repository remote points to the intended owner and repository.

Step-by-step fix

1Load the correct key into the SSH agentIf the key exists locally, add it to the active SSH agent before retrying the Git operation.84%
Command
ssh-add ~/.ssh/id_ed25519
ssh -T git@github.com
2Create and register a new SSH keyGenerate an Ed25519 key, then add the contents of the public .pub file to the SSH keys page of the intended GitHub account.71%
Command
ssh-keygen -t ed25519 -C "your-email@example.com"
cat ~/.ssh/id_ed25519.pub
3Correct the repository remoteVerify that origin points to the repository and account you intend to use.52%
Command
git remote -v
git remote set-url origin git@github.com:OWNER/REPOSITORY.git

Alternative solutions

Windows PowerShell

Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519

Run PowerShell as Administrator only when changing the ssh-agent service startup type.

macOS / Linux

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Use the actual private-key filename when it differs from id_ed25519.

HTTPS remote

git remote set-url origin https://github.com/OWNER/REPOSITORY.git
git remote -v

HTTPS uses a credential manager or personal access token instead of an SSH key.

Multiple GitHub accounts

ssh -G github.com | grep identityfile
ssh -vT git@github.com

Use host aliases in ~/.ssh/config when work and personal accounts require different keys.

Real example

Broken
shell
origin  git@github.com:wrong-account/private-repo.git (fetch)
origin  git@github.com:wrong-account/private-repo.git (push)
Corrected
shell
origin  git@github.com:correct-account/private-repo.git (fetch)
origin  git@github.com:correct-account/private-repo.git (push)

Frequently asked questions

Authentication proves who you are. You still need write permission to that repository and branch, and an organization may require SSO authorization for the key.

References