diff options
author | Aaron LI <aly@aaronly.me> | 2018-02-20 22:45:56 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-02-20 22:45:56 +0800 |
commit | 734e8fdab023199981b990094c1f2cedc7b28299 (patch) | |
tree | fcd192b552ec34b024ef9acc62e84d54911a2155 /_zsh/80-gpg.zsh | |
parent | 8370811d4d753045d7cfc12b06c83319d541583c (diff) | |
download | dotfiles-734e8fdab023199981b990094c1f2cedc7b28299.tar.bz2 |
zsh/gpg: add back the preexec hook to update tty for ssh agent support
Diffstat (limited to '_zsh/80-gpg.zsh')
-rw-r--r-- | _zsh/80-gpg.zsh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/_zsh/80-gpg.zsh b/_zsh/80-gpg.zsh index d9d5dbb..2cbb70c 100644 --- a/_zsh/80-gpg.zsh +++ b/_zsh/80-gpg.zsh @@ -26,6 +26,31 @@ if [ -n "${SSH_CONNECTION}" ] ;then export PINENTRY_USER_DATA="USE_CURSES=1" fi +# Let pinentry know which console to display in for `ssh-agent'. +# +# Since the 'ssh-agent' protocol does not contain a mechanism for telling +# the agent on which terminal/display it is running, gpg-agent's +# ssh-support can just use the TTY or X display when `gpg-agent' has been +# started, which may be before the X session startup. Therefore, when the +# switched to the X session, or login remotely through SSH, the `pinentry' +# will get popped up on whatever display the `gpg-agent' has been started +# or may just fail. In this case, a manual update is necessary. +# +# This will set startup TTY and X11 DISPLAY variables to the values of +# this session. +# +# Credits: +# * GnuPG: Commonly Seen Problems +# https://www.gnupg.org/documentation/manuals/gnupg/Common-Problems.html +# * `gpg-agent(1)': option `--enable-ssh-support' +# * http://blog.mrloop.com/workflow/2017/02/09/pin-entry.html +# +update-gpg-tty() { + gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1 || true +} +autoload -U add-zsh-hook +add-zsh-hook preexec update-gpg-tty + # Delete all identities from the `gpg-agent', which is similar to # `ssh-add -D`. # Credit: http://blog.mrloop.com/workflow/2017/02/09/pin-entry.html |