Home › Git

git@github.com: Permission denied (publickey). — how to fix

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Quick fix: Run ssh -T git@github.com to test. If it fails, create a key with ssh-keygen -t ed25519, add ~/.ssh/id_ed25519.pub to GitHub → Settings → SSH keys, and try again.

What it means

Git connected to GitHub over SSH, but none of the keys your SSH client offered belong to a GitHub account that can access the repository.

Step 1: test the connection

ssh -T git@github.com

Step 2: check that you have a key

ls -al ~/.ssh

Look for id_ed25519 and id_ed25519.pub (or id_rsa / id_rsa.pub). If there are none, create one:

ssh-keygen -t ed25519 -C "you@example.com"

Step 3: load the key into ssh-agent

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

Step 4: add the public key to GitHub

cat ~/.ssh/id_ed25519.pub

Copy the whole line and paste it in GitHub → Settings → SSH and GPG keys → New SSH key. Then run ssh -T git@github.com again.

Other causes

Host github.com
  User git
  IdentityFile ~/.ssh/my_github_key
  IdentitiesOnly yes

Last updated 2026-10-27.