Package: gpgkeys
Overviewgpgkeysis a Python program that allows to conveniently manageGnuPGkeys
and keyrings from the command line.
It comes in the form of a shell, with commands resembling GnuPG CLI commands and
their options.
Its main feature is end-to-end tab completion.gpgkeys also serves as testbed for the development of thekmdandrlPython
libraries.MotivationThe GnuPG CLI is very powerful – and with great power comes
great incomprehensibility.gpgkeys makes key management easy by:Providing a sensible subset of GnuPG commands, andUsing tab completion to streamline the input process and
guide the user through key management tasks.Example SessionEverything in gpgkeys can be tab completed: commands, help topics, option flags,
key ids, user names, file names, shell commands, and keyserver URLs.$ gpgkeys
gpgkeys 2.2 (type help for help)

gpgkeys> help

Available commands (type help <topic>):
=======================================
checksig  dump    fdump   genrevoke  list     quit     search  sign
clear     edit    fetch   help       listsig  recv     send    version
del       export  genkey  import     lsign    refresh  shell

Shortcut commands (type help <topic>):
======================================
!  .  ?  e  ll  ls

gpgkeys> help export
Usage: export <keyspec>
Options: --armor --clean --minimal --output --secret

Export keys to stdout or to a file

gpgkeys> ls Stefan
pub   1024R/E1F438AD 1995-10-03
uid                  Stefan H. Holek (RSA) <stefan@epy.co.at>

pub   1024D/355A2D28 2001-11-04
uid                  Stefan H. Holek <stefan@epy.co.at>
sub   2048g/A27E0DBC 2004-10-27

gpgkeys> export --armor 355A2D28 > stefan.asc
gpgkeys> .ls
alice.asc             stefan.ascFeaturesThe order of options and arguments on the command line is not important:gpgkeys> export 355A2D28 --armor > stefan.ascCommand lines prefixed with ‘.’ or ‘!’ are executed by the shell.
You can usecdto change the current directory,umaskto change the umask, and of course everything else:gpgkeys> .cd subdir/
gpgkeys> .pwd
/home/stefan/subdirYou can use input/output redirects and pipes:gpgkeys> export 355A2D28 | pgpdump | lessTo see the commands sent to GnuPG, run gpgkeys with the-voption:$ gpgkeys -v
gpgkeys 2.2 (type help for help)

gpgkeys> ls 355A2D28
gpgkeys: gpg --list-keys 355A2D28
pub   1024D/355A2D28 2001-11-04
uid                  Stefan H. Holek <stefan@epy.co.at>
sub   2048g/A27E0DBC 2004-10-27For everything you ever wanted to know about GnuPG commands, type:gpgkeys> .man gpggpgkeys can be invoked with arguments, in which case it does not enter
the command loop:$ gpgkeys export --armor 355A2D28 > stefan.ascKeyserversFor the send, recv, search, and refresh commands to work, at least one
keyserver should be configured in gpg.conf. For example:keyserver ldap://keyserver.pgp.com
keyserver hkps://hkps.pool.sks-keyservers.netThe last keyserver in gpg.conf becomes the default keyserver.
All keyservers become available for completion after the--keyserveroption.UnicodeOpenPGP allows user IDs to be either Latin-1 or UTF-8 encoded.
To find keys with non-ASCII IDs, GnuPG requires search strings to be
encoded the right way.gpgkeys’ key completion keeps track of the original encodings, and every name
you tab-complete will automatically be encoded the way GnuPG expects.
You may sometimes see ‘?’ characters in place of non-ASCII characters on the
command line, which are a result of the above and no reason for concern.Developmentgpgkeys development is hosted onGitHub. It also has anissue trackerthere.InstallationInstallation requires Python 2.7 or higher.Note: gpgkeys uses therllibrary which contains a C extension. It is a good
idea to review itsinstallation instructionsand make sure all dependencies
are in place.To install thegpgkeysscript, type:pip install gpgkeysThen put it on your system PATH by e.g. symlinking it to/usr/local/bin.RequirementsEither thegpg2command or thegpgcommand must be available on the
system PATH.Changelog2.2 - 2022-11-17Upgrade to rl 3.1 and kmd 2.4.
[stefan]Replace deprecatedpython setup.py testin tox.ini.
[stefan]Remove deprecatedtest_suitefrom setup.py.
[stefan]Add a pyproject.toml file.
[stefan]Include tests in sdist but not in wheel.
[stefan]2.1 - 2019-03-20Fix import error.
[stefan]2.0 - 2019-03-20Try thegpg2binary first, if not found fall back togpg.
[stefan]Always add--fixed-list-modeto--with-colons.
[stefan]Add--ask-cert-leveloption.
[stefan]Stop using 2to3.
[stefan]Fix documentation bug: The send command only accepts key IDs.
[stefan]Fix newline glitch in sign and lsign commands.
[stefan]1.23 - 2012-10-07Improve code for the benefit of 2to3.
[stefan]Rewrite Unicode support.
[stefan]Upgrade to rl 2.4 for Python 3.3 support.
[stefan]1.22 - 2012-06-24The--keyserveroption now overrides any preferred keyserver
configured for a key.
[stefan]1.21 - 2012-05-10Fix verbose output.
[stefan]Switch to a happier looking Sphinx theme.
[stefan]String and filename quoting was not respected when gpgkeys was
invoked with arguments. Fixed by requiring kmd >= 2.2.
[stefan]1.20 - 2012-04-27Save the tty state before executing subprocesses, restore afterwards.
[stefan]Support Python 2.5.
[stefan]Require term >= 2.0.
[stefan]1.19 - 2012-04-14Include command aliases in help screens.
[stefan]Return useful exit codes when gpgkeys is invoked with arguments.
[stefan]Fix “double prompt” issue when the edit menu was exited with ^D.
[stefan]The import and fdump commands now support input redirection via ‘<’.
[stefan]1.18 - 2011-11-05In Python 3, make sure the input function accepts surrogates.
Also see Pythonissue 13342.
[stefan]Keyserver completion broke when it failed to find a gpg.conf file.
[stefan]The import command ignored option flags when reading from stdin.
[stefan]Add pretty Sphinx-based docs.
[stefan]Require kmd >= 2.1.
[stefan]1.17 - 2011-10-06Use the new aliases dictionary to set up command aliases.
[stefan]Make sure error messages go to stderr.
[stefan]Ignore signals when a pager application is in the foreground.
[stefan]Require kmd >= 2.0.
[stefan]1.16.1 - 2011-07-25Fix history file handling silently broken in 1.16.
[stefan]1.16 - 2011-07-14Use kmd.Kmd instead of cmd.Cmd as base class.
[stefan]Depend on rl through the kmd dependency only.
[stefan]1.15 - 2011-05-05Require rl >= 1.14.
[stefan]1.14 - 2011-03-24Add ‘!’ and ‘.’ to shortcut commands so they show up in help.
[stefan]Drop Python 2.5 support in favor of faster byte string operations
in later Python versions.
[stefan]1.13 - 2011-03-11Require rl >= 1.13.
[stefan]1.12 - 2010-05-21Print help when required command arguments are missing.
[stefan]Require rl >= 1.11.
[stefan]1.11 - 2010-05-07Change an import statement so 2to3 is able to resolve it.
[stefan]1.10 - 2010-05-05Refactor completions: Extract generic parts into base class.
[stefan]Require rl >= 1.10.
[stefan]1.9 - 2010-03-07Rename the del command’s –all option to –secret-and-public.
[stefan]Require rl >= 1.6.
[stefan]1.8.2 - 2010-03-01Fix failing tests under Python 3 on Linux.
[stefan]1.8.1 - 2010-02-25Restore Python 2.5 compatibility. D’oh.
[stefan]1.8 - 2010-02-25Support Python 3 via distribute.
[stefan]The –fingerprint option may be given more than once.
[stefan]1.7.1 - 2010-02-13Depend on rl >= 1.4.1 explicitly so setuptools does not forget to upgrade
it as well.
[stefan]1.7 - 2010-02-13Change license to GPL.
[stefan]1.6 - 2010-01-31Add –clean and –minimal import/export options to respective commands.
[stefan]Fix –merge-only import option of keyserver commands.
[stefan]Remove the –yes option again since it has no apparent effect.
[stefan]1.5 - 2010-01-26Remove obsolete –secret option from the import command.
[stefan]Userid completion is now triggered by any kind of quoting.
[stefan]Allow to specifiy command line options after the argument.
[stefan]1.4 - 2010-01-20Extend the quoting and dequoting API to make it more (re)usable.
[stefan]Dequoting didn’t work right when the default quoting character
was single quote.
[stefan]Tildes in quoted filenames could cause quotes to be closed even
if the tilde-expanded name matched a directory.
[stefan]1.3 - 2010-01-03Cut down on infrastructure slack in filename completion. The
individual strategies are very small.
[stefan]Remove logging as it clutters up the code.
[stefan]Add an example session to the README.
[stefan]1.2 - 2009-11-24Extend keyid completion to also complete userids and names.
[stefan]Extract filename completion functionality into functions,
as it is useful in other places as well.
[stefan]1.1 - 2009-11-16Allow to specify the filename quoting style on the command line
to ease experimentation.
[stefan]Filename completion: By dequoting early on we can skip a problematic
hook and regain control over tilde expansion. Also see rlissue/3.
[stefan]1.0 - 2009-11-08Initial release.