# GitHub says invalid signature? Your key type may be the problem

> If your key predates 2021 and suddenly fails, GitHub now requires sha2 signing.

Source: https://fullbytedeveloper.com/blog/gh-ssh-rsa
Published here: 2026-11-20, updated 2026-12-03

GitHub's 2021 SSH cut-over dropped SHA-1 signatures for RSA keys, so an old RSA key can fail while HTTPS remotes still work [1]. Generate an ED25519 key, add the public half in GitHub settings, and point your Host block at that file. Confirm the key type with ssh-keygen before you dig into firewall myths.

## Quick start: new ED25519 key

GitHub's own generate-key docs walk Mac, Windows, and Linux through `ssh-keygen` and the agent [2]. On a Linux box:

```bash
ssh-keygen -t ed25519 -C "you@example.com" -f /tmp/ssh-demo-keys/id_ed25519 -N ""
ssh-keygen -l -f /tmp/ssh-demo-keys/id_ed25519.pub
```

Captured output from a fresh key on this machine:

```text
256 SHA256:rpaSt538a7noySfltGERiIAsfJtkHHqDRHV4FMQ13ks demo@example.com (ED25519)
```

Copy the `.pub` file into GitHub under Settings, SSH and GPG keys. Then test:

```bash
ssh -T -i /tmp/ssh-demo-keys/id_ed25519 -o IdentitiesOnly=yes git@github.com
```

A success line names your GitHub user. A failure that still mentions publickey after the new key is uploaded usually means the agent offered a different key first. Put `IdentitiesOnly yes` and an explicit `IdentityFile` on the `Host github.com` block so only that key is tried. [Stop typing the full SSH command every time](/blog/ssh-config) covers that Host layout in detail.

## Why RSA keys broke

RSA keys themselves were not banned. GitHub's 2021 post explains that older clients sign with SHA-1 when they use the `ssh-rsa` signature type, and that SHA-1 is weak [1]. OpenSSH 7.2 and newer can use `rsa-sha2-256` and `rsa-sha2-512` for the same RSA key material. Keys uploaded after the November 2, 2021 cut-off were required to use SHA-2 signatures during brownouts and after the change became permanent [1].

If your laptop still only offers SHA-1 for RSA, GitHub rejects the signature. The error looks like a bad key even when the private file is fine. ED25519 keys never depended on that SHA-1 path, which is why generating one is the shortest fix [1][2].

## See RSA versus ED25519 on disk

```bash
ssh-keygen -t rsa -b 2048 -f /tmp/ssh-demo-keys/id_rsa -N "" -C "legacy@example.com" >/dev/null
ssh-keygen -l -f /tmp/ssh-demo-keys/id_rsa.pub
ssh -Q PubkeyAcceptedAlgorithms | tr ',' '\n' | grep -E 'rsa|ed25519'
```

Captured fingerprint line:

```text
2048 SHA256:+7Jl0lCQlwNzp0ScWrnjymTC3P5NpaRfWr+4Ff2SL+I legacy@example.com (RSA)
```

Captured algorithm names from this OpenSSH (excerpt):

```text
ssh-ed25519
rsa-sha2-256
rsa-sha2-512
ssh-rsa
```

`ssh-rsa` in that list is the old SHA-1 signature algorithm name. `rsa-sha2-256` and `rsa-sha2-512` are the SHA-2 forms GitHub wants for RSA [1]. A modern default config already prefers the SHA-2 names for RSA keys. Forcing `PubkeyAcceptedAlgorithms +ssh-rsa` re-enables the weak signature type; that is the opposite of a repair.

<figure>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 260" role="img" aria-label="Client offers rsa-sha2 or ed25519; GitHub accepts those and rejects SHA-1 ssh-rsa">
  <defs>
    <marker id="ghSshArrow" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto">
      <path d="M0,0 L8,3 L0,6 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="720" height="260" rx="12" fill="#0b1f3a"/>
  <text x="24" y="36" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="16" font-weight="700">git@github.com auth</text>
  <rect x="24" y="56" width="200" height="72" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="36" y="84" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">ED25519 key</text>
  <text x="36" y="108" fill="#14b8a6" font-family="ui-monospace, monospace" font-size="14">ssh-ed25519</text>
  <rect x="24" y="148" width="200" height="72" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="36" y="176" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">RSA + SHA-2</text>
  <text x="36" y="200" fill="#14b8a6" font-family="ui-monospace, monospace" font-size="14">rsa-sha2-256/512</text>
  <path d="M224 92 H280" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#ghSshArrow)"/>
  <path d="M224 184 H280" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#ghSshArrow)"/>
  <rect x="288" y="88" width="160" height="96" rx="8" fill="#123052" stroke="#f59e0b" stroke-width="2"/>
  <text x="300" y="124" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">GitHub SSH</text>
  <text x="300" y="148" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">accepts</text>
  <path d="M448 136 H504" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#ghSshArrow)"/>
  <rect x="512" y="56" width="184" height="72" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="524" y="84" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">session OK</text>
  <text x="524" y="108" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">clone / push</text>
  <rect x="512" y="148" width="184" height="72" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="524" y="176" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">SHA-1 ssh-rsa</text>
  <text x="524" y="200" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">rejected</text>
</svg>
</figure>

*GitHub accepts ED25519 and RSA with SHA-2 signatures; SHA-1 ssh-rsa signing is what the 2021 cut-over removed.*

## Keep RSA only when the client is new enough

If you must keep an RSA key temporarily, upgrade OpenSSH (or Git for Windows's bundled SSH) so `ssh -Q PubkeyAcceptedAlgorithms` lists `rsa-sha2-256` and `rsa-sha2-512` [1][3]. Then wire a Host block that pins the key:

```text
Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes
```

Check the resolve without opening a session:

```bash
cat > /tmp/ssh-demo-keys/config <<'EOF'
Host github.com
  HostName github.com
  User git
  IdentityFile /tmp/ssh-demo-keys/id_ed25519
  IdentitiesOnly yes
EOF
ssh -F /tmp/ssh-demo-keys/config -G github.com | egrep '^(user|hostname|identityfile|identitiesonly) '
```

Captured output:

```text
user git
hostname github.com
identitiesonly yes
identityfile /tmp/ssh-demo-keys/id_ed25519
```

Do not add `PubkeyAcceptedAlgorithms +ssh-rsa` thinking it "forces sha2." That flag restores the old algorithm name. Prefer ED25519 and retire the RSA key in GitHub once clones work [1][2].

## Mistakes that look like network outages

Uploading a new public key but leaving five other keys in the agent, so GitHub sees failed attempts before the right one. `IdentitiesOnly yes` stops that [3].

Debugging with `git clone https://...` while the failure only happens on `git@github.com` remotes. HTTPS never exercises your SSH key [1].

Editing `/etc/ssh/ssh_config` system-wide instead of `~/.ssh/config`, then wondering why a CI user still offers RSA SHA-1.

Copying only the private key to a new laptop and forgetting the `.pub` registration on GitHub, or pasting the private key into the GitHub form.

Treating "invalid signature" as a repo ACL change. Check `ssh-keygen -l` and the signature algorithms before opening a ticket with your host.

## Corporate laptops and old Git installs

Teams stuck on an ancient Git for Windows build, or on a locked-down image that ships OpenSSH 7.1, still hit SHA-1 RSA failures against GitHub even when the private key file is perfect [1]. The durable fix is still ED25519 on a client that supports it. If IT must approve a package bump, collect `ssh -V`, `ssh -Q PubkeyAcceptedAlgorithms`, and the failing `ssh -vT git@github.com` excerpt so the ticket is about signature algorithms, not "GitHub is down."

Some managed configs set `PubkeyAcceptedAlgorithms` narrowly. If ED25519 is missing from the negotiated list in `ssh -v`, fix the client policy before rotating keys a second time. Host key algorithms (`HostkeyAlgorithms`) are a separate list that covers how you verify GitHub's server key; do not confuse them with the client signature algorithms that sign your user key [1].

## Multiple GitHub accounts on one laptop

People who use a work GitHub Enterprise account and a personal account often keep two keys. Give each a Host alias:

```text
Host github.com-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_work
  IdentitiesOnly yes

Host github.com-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_personal
  IdentitiesOnly yes
```

Point remotes at `git@github.com-work:org/repo.git` so the right key is offered. Without `IdentitiesOnly`, the agent may try the personal key against work first and produce confusing failures that look like the 2021 signature issue [3].

## After the new key works

Remove the old RSA public key from GitHub once every machine you use has the ED25519 key. Keep private keys mode `600` and the `.ssh` directory mode `700` so OpenSSH does not refuse them [3]. For deploy keys, give each repo its own ED25519 file and a dedicated Host alias so personal keys never get offered to production remotes.

CI deploy keys deserve the same ED25519 treatment. A self-hosted runner with a ten-year-old RSA key in `/home/runner/.ssh` will fail the same way a laptop does. Rotate the runner key, update the GitHub deploy-key setting, and confirm `ssh -T` under the runner user before the next nightly job.

Hardware security keys that speak `sk-ssh-ed25519@openssh.com` are another path GitHub documents for generate-key flows [2]. They avoid leaving a decryptable private file on disk. Use them when the laptop is shared or high risk; otherwise a file-backed ED25519 key with a passphrase and agent is enough for most developers.

When `ssh -T git@github.com` greets you and `git fetch` over SSH succeeds, the signature path is fine. Leave the SHA-1 era keys in the archive folder, not in the agent.

Verbose failures still deserve one careful read of the offered algorithms. In `ssh -v` output, look for lines that name `rsa-sha2-256`, `rsa-sha2-512`, or `ssh-ed25519` during publickey auth. If the client only proposes `ssh-rsa` for your user key, upgrade OpenSSH or switch to ED25519 before you rotate credentials a third time [1]. Keep a short internal note with the working `ssh -V` so the next teammate does not rediscover the same brownout timeline from 2021. Paste that note next to the Host block in your team wiki when onboarding a new laptop image.

For Host blocks and IdentityFile pinning, see [SSH config Host blocks](/blog/ssh-config) and [SSH keys for developers](/blog/ssh-keys-for-developers). Browse the [Dev tools topic](https://fullbytedeveloper.com/blog/topic/dev-tools).

Send this to the friend who still has an old RSA key that GitHub rejects.

Image: An old worn key token bouncing off a closed amber gate, while a newer teal key with a more complex tooth pattern slides through the same gate into a remote repository cube, shown as unmarked geometric solids on a dark navy field with no typography or logos.
https://fullbytedeveloper.com/media/gh-ssh-rsa/gh-ssh-rsa-venice.webp
An older key type can start failing at the gate. Use a modern signing key instead.

## Sources

1. [GitHub blog: improving Git protocol security (2021)](https://github.blog/2021-09-01-improving-git-protocol-security-github/)
2. [GitHub docs: generate a new SSH key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
3. [OpenBSD man: ssh-keygen](https://man.openbsd.org/ssh-keygen)
