I have a service that checks my email regularly, and I use gpg to encrypt my email password. The problem is that every time I lock my computer or after a certain amount of time gpg shows a graphical interface to ask for the password.

Is there a way, even if it's less secure, to have gpg remember my password until I restart my computer? Or perhaps use my log-in password which I have to input anyways to unlock my computer? If that's not possible with gpg, is there another tool that can achieve this?

  • 1
    What about removing the password from your PGP private key. Even better, you can create a new PGP key-pair without a passphrase and use it only for this purpose; That way if the private key is stolen it could only be used to decrypt that one password. Jan 22, 2019 at 9:27
  • That sounds like what I need. Can you provide me with some pointers on how to create a new key-pair without a passphrase? Thanks
    – Tohiko
    Jan 22, 2019 at 10:48
  • 1
    You can use gpg --quick-gen-key and simply press ENTER when asked for a passphrase. Jan 23, 2019 at 11:36

1 Answer 1


GPG can not directly be set to keep the password until restart, but you can change the time it caches the passwords to a very long time, e.g. a year. Add the following lines to $GNUPGHOME/gpg-agent.conf ($GNUPGHOME is usually ~/.config/gnupg):

default-cache-ttl 31536000
max-cache-ttl 31536000

This sets the time for caching passphrases to one year (31536000 seconds). default-cache-ttl is the normal caching time, which is reset when the key is used (so on each use it is cached longer), while max-cache-ttl limits the total time including extensions.

You must log in to answer this question.

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