ZSH plugin. Goodies for gpg-agent
like autostart, SSH_AUTH_SOCK
export
and
remote socket cleanup, etc.
The plugin is designed as a Prezto module, but it's also compatible with other plugin managers.
Manually start gpg-agent
in case it's used as agent for SSH.
Set the startup TTY
and X-DISPLAY
variables to direct future pinentry invocations
to another screen. (The settings are needed when gpg-agent
is used for SSH auth.)
On remote machine (SSH connection), force ncurses-based prompt for paraphrase input.
The plugin also remove the agent socket when logout from SSH, cause overwriting an existing socket file in remote forwarding is disabled by default.
The plugin is designed as a replacement for existing gpg plugins from Oh-My-ZSH and Prezto, both of which are outdated:
gpg
command auto starts thegpg-agent
. There's no need to start it manually unlessgpg-agent
is used for SSHGPG_AGENT_INFO
is removed in GnuPG 2.1.0- New subcommands are introduced to detect socket location
The only ZSH plugin manager solves the time-consuming init for
nvm
, nodenv
, pyenv
, rvm
, rbenv
, thefuck
, fasd
, etc,
with its amazing async Turbo Mode.
zinit ice wait'1' lucid
zinit light laggardkernel/zsh-gpg-agent
The only framework does optimizations in plugins with sophisticated coding skill:
- refreshing
.zcompdump
every 20h - compiling
.zcompdump
as bytecode in the background - caching init script for fasd
- saving
*env
startup time withinit - --no-rehash
forrbenv
,pyenv
,nodenv
- removing the horribly time-consuming
brew command
fromcommand-not-found
mkdir -p ${ZDOTDIR:-$HOME}/.zprezto/contrib 2>/dev/null
git clone https://github.com/laggardkernel/zsh-gpg-agent.git ${ZDOTDIR:-$HOME}/.zprezto/contrib/gpg-agent
Using gpgconf --list-dir agent-socket
to get the socket location is not the
fastest, but the most compatible. To speed up the location detection for
sockets, you may wanna set the following variables before the plugin is loaded.
if [[ $OSTYPE == darwin* ]]; then
_GPG_AGENT_SOCK="${HOME}/.gnupg/S.gpg-agent"
_GPG_AGENT_SSH_SOCK="${HOME}/.gnupg/S.gpg-agent.ssh"
elif [[ $OSTYPE == linux* ]]; then
_GPG_AGENT_SOCK="${XDG_RUNTIME_DIR}/.gnupg/S.gpg-agent"
_GPG_AGENT_SSH_SOCK="${XDG_RUNTIME_DIR}/.gnupg/S.gpg-agent.ssh"
fi
gpg-agent
auto start and SSH_AUTH_SOCK
export
could be controlled by
zstyle
settings,
zstyle ':prezto:module:gpg-agent:auto-start' local 'yes' # default yes
zstyle ':prezto:module:gpg-agent:auto-start' remote 'no' # default no
Note: gpg-agent
autostart is disabled by default on remote machine.
- Cache
ssh-agent-support
detection for GnuPG
The MIT License (MIT)
Copyright (c) 2021 laggardkernel