Running gpg-agent on Ubuntu
26 Nov 2015 in TIL
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.
bash
# First, install gpg-agentsudo 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; thenGPG_AGENT_INFO=`cat $HOME/.gpg-agent-info | cut -c 16-`else# No, gpg-agent not available; start gpg-agenteval `gpg-agent --daemon --no-grab --write-env-file $HOME/.gpg-agent-info`fiexport GPG_TTY=`tty`export 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