GPG key created with sudo cannot be used to sign Git commit

When I attempt to create a new key for Github with this command:

gpg --full-gen-key

I keep receiving this error:

gpg: no writable public keyring found: Not found
Key generation failed: Not found

So I added sudo in front of the command and the key was created. Then I added the key to Github and set the signing key to Git. However, when I tested the key with a new commit, it gave me this error:

error: gpg failed to sign the data
fatal: failed to write commit object

I assumed it's because I used sudo but I cannot create a key otherwise. It keeps giving the public keyring error every I use gpg alone. Any clarification on this is appreciated.

2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like