Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git does not ask me for gpg passphrase and fails my commit

Tags:

git

gnupg

When I do git commit -a -S -m "Commit Message", I get this error:

You need a passphrase to unlock the secret key for user: "Username (Gpg Key) <email-id>" 2048-bit RSA key, ID 2487BE7C, created 2016-10-03  error: gpg failed to sign the data fatal: failed to write commit object 

But, it doesn't even ask/prompts for my passphrase when I commit. So, how and where do I enter my passphrase while using gpg's -S flag?

like image 371
Dawny33 Avatar asked Oct 03 '16 10:10

Dawny33


People also ask

Where is GPG passphrase stored?

The passphrase itself is not stored anywhere and thus cannot be displayed. The decryption process works anyway by repeatedly applying a secure hash algorithm to a concatenation of the passphrase being input and a salt value (a random number) read from the key ring.

What is GPG key in Git?

About GPG keys GPG is a command line tool used together with Git to encrypt and sign commits or tags to verify contributions in Bitbucket. In order to use GPG keys with Bitbucket, you'll need generate a GPG key locally, add it to your Bitbucket account, and also set it up for use with Git.


2 Answers

I had the similar thing. I had the gpg and gpg2 binaries, both pointing to GPG version 2.0.30. I wasn't being prompted for my passphrase.

In your bash profile (I did it in my .zshrc file) add the following line:

export GPG_TTY=$(tty) 
like image 99
DiegoRBaquero Avatar answered Oct 22 '22 07:10

DiegoRBaquero


It stopped prompting me, so I had to kill the daemon

ps aux | grep gpg mark              3129   0.0  0.0  4397952    820   ??  Ss    8Mar19   0:28.84 gpg-agent --homedir /Users/Mark/.gnupg --use-standard-socket --daemon mark             18137   0.0  0.0  4286492    848 s000  R+    3:43pm   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn gpg 

then

sudo kill -9 3129 

Then it worked. It may be a slightly different issue.

like image 23
Rambatino Avatar answered Oct 22 '22 08:10

Rambatino