Commit list showing a verified signature

error: gpg failed to sign the data

A couple of months ago I noticed that commits I’ve done through the GitHub web interface were receiving a “Verified” badge while commits done through the Git command line in WSL (Windows Subsystem for Linux) at my local dev machine weren’t.

I’m all for badges so I followed the steps found at About commit signature verification to setup GPG signing. The thing is, there was something still missing and as a result, when trying to commit I was getting an error message as follows:

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

Fortunately, the solution is simple. Export a variable named GPG_TTY as follows:

export GPG_TTY=$(tty)

I ended appending it to ~/.bashrc so as to persist it between terminal sessions.

Published by

Alfred Myers

I have been interested in computers since I got my hands on a magazine about digital electronics back in 1983 and programming them has been paying the bills since 1991. Holding a dozen Microsoft certifications and being awarded Microsoft MVP in C# for five years in a row starting in 2007, recently I've been educating myself on open source technologies such as Linux, networking and the open web platform.

2 thoughts on “error: gpg failed to sign the data”

  1. For the benefit of your readers please consider revising this post to explain why this worked for you.

    1. I’m not sure why this setting has to be done manually, but it is stated in the documentation for gpg-agent (http://manpages.ubuntu.com/manpages/bionic/man1/gpg-agent.1.html) and it has been this way for a long, long time (https://github.com/gpg/gnupg/blame/abaa732d6b0cade814bdbda36a2d0cb5d79b1684/doc/gpg-agent.texi#L84).
      There’s an opened issue over at GnuPG (https://dev.gnupg.org/T3412) describing the issue on Debian, but I was able to reproduce the error on Ubuntu 18 and 19, and CentOS 8.0 as well.

Leave a Reply to jhabdas Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.