GitHub Permission denied (publickey) - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

GitHub Permission denied (publickey)
====================================

### [\#Git](https://rocketeersapp.com/knowledge/git)

When git clone, pull or push over SSH fails with this error, GitHub did not accept your SSH key. Usually the key is not generated, not added to your account, or not loaded into the agent.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on June 23, 2026 · 1 minute read

1. [About the error](#content-about-the-error)
2. [Why do I see this error](#content-why-do-i-see-this-error)
3. [Solution](#content-solution)
4. [Test the connection](#content-test-the-connection)
5. [Generate a key if you don't have one](#content-generate-a-key-if-you-dont-have-one)
6. [Add the public key to GitHub](#content-add-the-public-key-to-github)
7. [Load the key into the agent](#content-load-the-key-into-the-agent)
8. [Wrong remote protocol](#content-wrong-remote-protocol)

[\#](#content-about-the-error "Permalink")About the error
---------------------------------------------------------

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

```

You're connecting to GitHub over SSH, and GitHub rejected the authentication because none of the keys your client offered matches a key on your account.

[\#](#content-why-do-i-see-this-error "Permalink")Why do I see this error
-------------------------------------------------------------------------

- You haven't generated an SSH key yet.
- The public key isn't added to your GitHub account.
- The key exists but isn't loaded into the SSH agent.
- You're using an HTTPS-style setup but a remote that expects SSH (or vice versa).

[\#](#content-solution "Permalink")Solution
-------------------------------------------

### [\#](#content-test-the-connection "Permalink")Test the connection

GitHub has a dedicated endpoint for this. A success looks like a greeting, not a shell:

 ```
ssh -T git@github.com

```

If it says `Hi !`, your key works and the problem is the repository remote, not auth. If it says `Permission denied`, continue below.

### [\#](#content-generate-a-key-if-you-dont-have-one "Permalink")Generate a key if you don't have one

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

```

Press enter to accept the default location (`~/.ssh/id_ed25519`).

### [\#](#content-add-the-public-key-to-github "Permalink")Add the public key to GitHub

Copy the **public** key (`.pub`) and paste it into GitHub under Settings → SSH and GPG keys → New SSH key:

 ```
cat ~/.ssh/id_ed25519.pub

```

### [\#](#content-load-the-key-into-the-agent "Permalink")Load the key into the agent

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

```

### [\#](#content-wrong-remote-protocol "Permalink")Wrong remote protocol

If your account is set up for SSH but the repo was cloned over HTTPS (or the reverse), switch the remote URL:

 ```
git remote set-url origin git@github.com:you/repo.git

```

For the general server-side version of this error (your own servers rather than GitHub), see [SSH Permission denied (publickey)](/ssh-permission-denied-publickey).

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Git](https://rocketeersapp.com/knowledge/git)

- [Removing tracked files in Git that should have been ignored](https://rocketeersapp.com/knowledge/removing-tracked-files-git)
- [Change casing of file or directory in Git](https://rocketeersapp.com/knowledge/change-casing-of-file-or-directory-in-git)
- [Git fatal: refusing to merge unrelated histories](https://rocketeersapp.com/knowledge/git-refusing-to-merge-unrelated-histories)
- [Git fatal: not a git repository](https://rocketeersapp.com/knowledge/git-not-a-git-repository)
- [Git: Updates were rejected (non-fast-forward)](https://rocketeersapp.com/knowledge/git-updates-were-rejected-non-fast-forward)
