Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode with ubuntu + wsl 2 never prompts for gpg passphrase even after configuration just "failed to write commit data"

I'm trying to get vscode to prompt for passphrase when trying to commit as it does in windows OR at least make the time between having to enter the passphrase a lot longer.

I'm using latest on ubuntu + WSL 2, both installed today.

GPG works in the CLI if I run a test as follows:

echo "test" | gpg --clearsign

I'm being prompted for a passphrase and all is well. Then I'd be able to sign commits in vscode temporarily.

Is there an option to make the time between entering the passphrase a lot longer at least as a workaround?

EDIT:

I also have to enter this everytime I reboot my computer:

export GPG_TTY=$(tty)

Otherwise the above workaround won't work. It's been insane trying to fix this, probably spent at least 1 full day but to no use.

like image 826
SebastianG Avatar asked May 21 '20 16:05

SebastianG


1 Answers

In your ~/.gnupg/gpg-agent.conf file, add the following:

default-cache-ttl 28800
max-cache-ttl 28800

You can also add the following to your ~/.bashrc so you do not have to manually enter it each time:

export GPG_TTY=$TTY
echo "test" | gpg --clearsign > /dev/null 2>&1

This prompts me for my password once on start and should cache for 8 hours. The > /dev/null 2>&1 bit hides the output. Currently, this is the workaround I am using--which is not ideal but bearable.

like image 122
Tan Avatar answered Nov 15 '22 10:11

Tan