Skip to content

Instantly share code, notes, and snippets.

@mevanlc
Last active May 8, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mevanlc/e68a13d6b42c9dd09296b5c1e27e6d45 to your computer and use it in GitHub Desktop.
Save mevanlc/e68a13d6b42c9dd09296b5c1e27e6d45 to your computer and use it in GitHub Desktop.
Reusing gpg-agent across login sessions (bashrc) on a headless server
# Run:
# sudo apt-get install gnupg-agent
# sudo apt-get install pinentry-curses
# Edit:
# $HOME/.gnupg/gpg-agent.conf:
# pinentry-program /usr/bin/pinentry-curses
# default-cache-ttl 28800000
# max-cache-ttl 28800000
# Edit:
# $HOME/.subversion/config:
# password-stores = gpg-agent
if [ -f /usr/bin/gpg-agent ]; then
export GPG_TTY=`tty`
GPG_AGENT_INFO_FILE="$HOME/.gpg-agent-info"
if [ -f "$GPG_AGENT_INFO_FILE" ]; then
source "$GPG_AGENT_INFO_FILE"
eval $(cat $GPG_AGENT_INFO_FILE)
eval $(cut -d= -f 1 < $GPG_AGENT_INFO_FILE | xargs echo export)
fi
gpg-connect-agent /bye &>/dev/null
if [ ! $? -eq 0 ]; then
pkill -x gpg-agent -u $UID
gpg-agent --allow-preset-passphrase --daemon --write-env-file="$GPG_AGENT_INFO_FILE" >/dev/null
source "$GPG_AGENT_INFO_FILE"
eval $(cat $GPG_AGENT_INFO_FILE)
eval $(cut -d= -f 1 < $GPG_AGENT_INFO_FILE | xargs echo export)
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment