Seed password once into gpg-agent
In addition to the other methods already mentioned here, it is possible to seed your gpg-agent with a passphrase; you may build that into a startup script, and require manual intervention once, when your build machine starts up. Such a setup is slightly more secure, since the passphrase only resides in memory. However, an attacker able to read memory contents could still steal your passphrase and then distribute malicious software in your name
fist stop an existing agent
gpgconf --kill gpg-agent
then start a new instance and allow to inject the passphrase; moreover, we can increase the time-to-live here
gpg-agent --default-cache-ttl 3600 --max-cache-ttl 86400 --allow-preset-passphrase --daemon
inject the passphrase of your signing subkey — You will be prompted to enter the passphrase when this command runs.
/usr/lib/gnupg/gpg-preset-passphrase --preset <keygrip>
For this to work, you need the "keygrip" of your signing subkey (not the master key!). Use gpg
to find out that information
gpg --with-keygrip --list-secret-key <YourUserID>
The signing subkey is listed below the master key and the Email addresses, it is typically marked as ssb
and [S]
or [SA]
Hints
sometimes you need to export GPG_TTY=$(tty)
for the pinentry
to work
you may start a sub-shell from the gpg-agent
gpg-agent [..further.options..] --daemon /bin/bash
this way, the agent exits when the sub-shell exits and any password you set in the sub-shell is gone afterwards.
debsign
, see this answer