Git Product home page Git Product logo

zsh-gpg-agent's Introduction

gpg-agent

License: MIT

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.

Features

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:

  1. gpg command auto starts the gpg-agent. There's no need to start it manually unless gpg-agent is used for SSH
  2. GPG_AGENT_INFO is removed in GnuPG 2.1.0
  3. New subcommands are introduced to detect socket location

Installation

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:

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

Settings

Socket Location

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

Auto Start

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.

TODO

  • Cache ssh-agent-support detection for GnuPG

License

The MIT License (MIT)

Copyright (c) 2021 laggardkernel

zsh-gpg-agent's People

Contributors

laggardkernel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mrreasonable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.