From 37140de930c744f38b8c15e416483248befad74e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 21 Jun 2011 21:09:59 -0400 Subject: [PATCH] Add gpg-agent post and scripts. --- posts/gpg-agent.mdwn | 28 ++++++++++++++++++++++++++++ posts/gpg-agent/gpg-agent-kill.sh | 5 +++++ posts/gpg-agent/gpg-agent-spawn.sh | 9 +++++++++ 3 files changed, 42 insertions(+) create mode 100644 posts/gpg-agent.mdwn create mode 100755 posts/gpg-agent/gpg-agent-kill.sh create mode 100755 posts/gpg-agent/gpg-agent-spawn.sh diff --git a/posts/gpg-agent.mdwn b/posts/gpg-agent.mdwn new file mode 100644 index 0000000..fca0c83 --- /dev/null +++ b/posts/gpg-agent.mdwn @@ -0,0 +1,28 @@ +The 2.X branch of [[GnuPG]] comes with [gpg-agent][] for caching +passphrases. The documentation is good, but here are my notes +outlining my usual usage. + +Add + + if [ -f "${HOME}/.gnupg/agent-info" ]; then + source "${HOME}/.gnupg/agent-info" + fi + +Start the agent with + + $ GPG_TTY=$(tty) + $ gpg-agent --daemon --write-env-file "${HOME}/.gnupg/agent-info" + $ echo "GPG_TTY='${GPG_TTY}'; export GPG_TTY" >> "${HOME}/.gnupg/agent-info" + $ source "${HOME}/.gnupg/agent-info" + +The `GPG_TTY` bit will spawn the `pinentry` call in the designated +TTY. This avoids troublesome issues like pinentry clobbering [[Mutt]] +if they are both using ncurses. + +When you are done with the agent, kill it with + + $ killall gpg-agent + $ rm -f "${HOME}/.gnupg/agent-info" + +[[!tag tags/linux]] +[[!tag tags/tools]] diff --git a/posts/gpg-agent/gpg-agent-kill.sh b/posts/gpg-agent/gpg-agent-kill.sh new file mode 100755 index 0000000..5ac9d3b --- /dev/null +++ b/posts/gpg-agent/gpg-agent-kill.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +FILE="${HOME}/.gnupg/agent-info" +killall gpg-agent +rm -f "${FILE}" diff --git a/posts/gpg-agent/gpg-agent-spawn.sh b/posts/gpg-agent/gpg-agent-spawn.sh new file mode 100755 index 0000000..432e69f --- /dev/null +++ b/posts/gpg-agent/gpg-agent-spawn.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# source me! + +FILE="${HOME}/.gnupg/agent-info" +GPG_TTY=$(tty) +#gpg-agent --daemon --enable-ssh-support --write-env-file "${FILE}" --pinentry-program "${HOME}/bin/pinentry" +gpg-agent --daemon --write-env-file "${FILE}" --pinentry-program "${HOME}/bin/pinentry" +echo "GPG_TTY='${GPG_TTY}'; export GPG_TTY" >> "${FILE}" +source "${FILE}" -- 2.26.2