summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2018-02-02 16:02:12 +0100
committerTharre <tharre3@gmail.com>2018-02-02 16:55:02 +0100
commit23a777d5f9dfc5572edb75c21737aca44c01aefa (patch)
tree0e1c83ef0718d9c853ec6ed2f7323e55b57eb07e
parentd453b2879431d32101c0761e97738845730f64fc (diff)
downloaddotfiles-23a777d5f9dfc5572edb75c21737aca44c01aefa.tar.gz
dotfiles-23a777d5f9dfc5572edb75c21737aca44c01aefa.tar.xz
dotfiles-23a777d5f9dfc5572edb75c21737aca44c01aefa.zip
gnupg: properly setup gpg-agent as ssh-agent
-rw-r--r--.pam_environment3
-rw-r--r--.zshrc16
2 files changed, 16 insertions, 3 deletions
diff --git a/.pam_environment b/.pam_environment
new file mode 100644
index 0000000..0a840fa
--- /dev/null
+++ b/.pam_environment
@@ -0,0 +1,3 @@
+SSH_AGENT_PID DEFAULT=
+SSH_AUTH_SOCK DEFAULT="${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh"
+GSM_SKIP_SSH_AGENT_WORKAROUND DEFAULT="true"
diff --git a/.zshrc b/.zshrc
index 6d84bf8..d68dcfb 100644
--- a/.zshrc
+++ b/.zshrc
@@ -185,9 +185,19 @@ alias open="xdg-open"
## env
export EDITOR=vim
-# use gpg-agent as ssh-agent
-gpg-connect-agent /bye > /dev/null 2>&1
-export SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
+## gpg-agent
+export GPG_TTY=$(tty)
+
+# Refresh gpg-agent tty in case user switches into an X session
+gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
+
+# if $SSH_AUTH_SOCK is not set or not pointing to a socket, use gpg-agent
+if [ ! -S "$SSH_AUTH_SOCK" ] && type "gpgconf" > /dev/null; then
+ unset SSH_AGENT_PID
+ if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
+ export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
+ fi
+fi
## zsh options