From the documentation, I can run gpg-agent with custom config like this and I think this is the official way:
The following gpg-agent.conf contains this:
allow-preset-passphrase default-cache-ttl 34560000 max-cache-ttl 34560000
and to run gpg-agent with custom config:
#!/bin/bash GPG_CONFIG_FILE="/opt/gpg-agent.conf" gpg-agent --options $GPG_CONFIG_FILE --daemon
From my observation, the gpg-agent reads the custom config perfectly with no issue.
But, then I notice that if a gpg-agent
is not running, then when I run a gpg command it will
automatically run gpg-agent. This are example of commands that will call gpg-agent and start it automatically:
1) echo RELOADAGENT | gpg-connect-agent # Reload and forget passphrase of gpg-agent 2) KEY_GRIP=$(gpg --with-keygrip --list-secret-keys $KEY_ID | grep -Pom1 '^ *Keygrip += +\K.*') # List key grip for that key_id
The problem is the above commands did not run gpg-agent with custom config. I'm writing a bash script where the config will be generated with predefined value automatically inside the script own path (if it does not exist). So the script will only use this custom config not in ~/.gnupg.
$ ls myscript.sh conf/gpg-agent.conf
How do I make the gpg-agent to use custom config when running the above example commands ?
If question 1) is not possible, how do I prevent gpg-agent from running when executing the commands example given above that will automatically run gpg-agent ?