Why does signing commit with SSH key fail with "invalid format?" and "failed to write commit object"?

Viewed 250

I followed GitHub's instructions for telling git about my SSH key, but when I tried to sign a commit

git commit -S

I got this error:

error: Load key 
"C:\\Users\\MyName\\AppData\\Local\\Temp/.git_signing_key_tmpC5KwFc": invalid format?

fatal: failed to write commit object

What might I be doing wrong?

1 Answers

Setup

For Git to successfully sign the commit,

  1. Git (v2.34 or later) needs to know about your SSH key
  2. The ssh-agent needs to be running
    • eval "$(ssh-agent -s)" to start it
  3. The ssh-agent needs to have your key
    • ssh-add -L to list existing keys
    • ssh-add ~/.ssh/id_ed25519 to add your key

Signing

Then you should be able to sign the commit!

git commit -S

Verifying

More on verifying your SSH-signed commits.

Related