Assuming I have a text file called prueba.txt
.
Hola
And I encrypt it with GPG as follows:
$ gpg -c prueba.txt
This asks me for a password and then generates the prueba.txt.gpg
. Now if you wanted to decrypt the file you would have to do the following:
$ gpg --decrypt prueba.txt.gpg
Which should ask me for the password of the file so it can decrypt it, but it doesn't. It just decrypts it without any password.
This may be normal behavior,
gpg
now usedgpg-agent
to manage private keys, and the agent caches the keys for a certain time (up to two hours by default, with a ten minute idle time). Which means that during that time you will not be asked for the password to decrypt.To change the default values, create or edit a file called
~/.gnupg/gpg-agent.conf
and use the following inputs:default-cache-ttl
specifies the amount of time a cache entry is kept after its last use, in seconds (600
default);max-cache-ttl
specifies the maximum amount of time a cache entry is kept, in seconds (7200
default).After changing them, you'll need to reload the config (try sending a
SIGHUP
togpg-agent
, or killing it directly withkill gpg-agent
).Source: gpg does not ask for password