Last active
May 8, 2019 16:10
-
-
Save mevanlc/e68a13d6b42c9dd09296b5c1e27e6d45 to your computer and use it in GitHub Desktop.
Reusing gpg-agent across login sessions (bashrc) on a headless server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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