I recently made it so that all my
git commits are automatically signed by my GPG key (yay!), but typing my passphrase for every commit got old very quickly.
Thankfully, you can run an agent (much like ssh-agent) to cache credentials for you.
# First, install gpg-agent
sudo apt-get install gnupg-agent
# Then, add the following to your .bashrc/.zshrc
# Invoke GnuPG-Agent the first time we login.
# Does `~/.gpg-agent-info' exist and points to gpg-agent process accepting signals?
if test -f $HOME/.gpg-agent-info && \
kill -0 `cut -d: -f 2 $HOME/.gpg-agent-info` 2>/dev/null; then
GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info | cut -c 16-`
# No, gpg-agent not available; start gpg-agent
eval `gpg-agent --daemon --no-grab --write-env-file $HOME/.gpg-agent-info`
Eventually, I'd like to have multiple different GPG identities and use something like
ssh-ident to manage them, but for now this is working for me