6

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.

SebastianG
  • 8,563
  • 8
  • 47
  • 111

1 Answers1

1

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.

Tan
  • 196
  • 3
  • 6
  • 1
    Also, as stated [here](https://unix.stackexchange.com/a/608921/296430), it its more reliable to use `export GPG_TTY=$TTY` command instead. – pyrsmk Dec 01 '20 at 15:07
  • Thank you, I made the update based on your suggestion. – Tan Dec 15 '20 at 20:27