I have searched the whole universe this error but i could not find any helpful tips.

I have created a key using keybase and added my public key to github gpg

my gpg --list-secret-keys --keyid-format LONG is this

sec   rsa4096/7E8*******60B47B 2021-03-06 [SC] [expires: 2037-03-02]
uid                 [ultimate] Fatih <********@live.be>
uid                 [ultimate] Fatih <[email protected]>
ssb   rsa4096/15BBF8A123C4AC1B 2021-03-06 [E] [expires: 2037-03-02]

my .gitconfig is this

        signingkey = 7E8*******60B47B
        email = [email protected]
        name = kgnfth
        gpgsign = true
        program = gpg

i added export GPG_TTY=$(tty) to my .zshrc file

Everytime i run git commit -m "first commit", i get this error

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

I dont see anything wrong with the signing key i also tried changing gpg to gpg2 but the same error appears

i am out of idea i need your help

Thank you.

  • why don't you create a key using gpg and then use that key, it might be an issue with the keybase key
    – john doe
    Mar 6, 2021 at 2:59
  • keybase uses your installed gpg program it has nothing to do with it i fixed my issue by adding gpg-agent plugin to my zshrc config Mar 6, 2021 at 4:28

2 Answers 2


As mentioned by the Accepted answer, Adding gpg-agent to the zsh plugins solves the problem. I later found out that exporting GPG_TTY is enough to make it work.

Add below line to .zshrc or .zprofile(prefer)

export GPG_TTY=$TTY

For extra detail, gpg seems to output the pin-entry process onto some other external source and not the current terminal being used. TTY holds the ref to the current terminal and thus exporting it as GPG_TTY solves the problem in this case.

  • Right, the zsh plugin does the same. Apr 9, 2022 at 5:43

i resolved my issue by adding gpg-agent plugin to my zshrc config file.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .