# derivepassphrase-vault(1) ## NAME derivepassphrase-vault – derive a passphrase using the vault derivation scheme ## SYNOPSIS
derivepassphrase vault [--phrase | --key] [--length n] [--repeat n] [--lower n] [--upper n] [--number n] [--space n] [--dash n] [--symbol n] SERVICE
derivepassphrase vault {--phrase | --key | … | --symbol n} … --config [--unset setting …] [--overwrite-existing | --merge-existing] [SERVICE]
derivepassphrase vault {--notes SERVICE | --delete SERVICE | --delete-globals | --clear}
derivepassphrase vault [--export-as {json | sh}] {--import PATH | --export PATH}
## DESCRIPTION Using a master passphrase, derive a passphrase for SERVICE, subject to length, character and character repetition constraints, in a manner compatible with James Coglan's vault(1). The derivation is strong: derived passphrases have as much entropy as permitted by the master passphrase and the passphrase constraints (whichever is more restrictive), and even if multiple derived passphrases are compromised, the master passphrase remains cryptographically difficult to discern from these compromised passphrases. The derivation is also deterministic, given the same inputs, thus the resulting passphrase need not be stored explicitly. The service name and constraints themselves also need not be kept secret; the latter are usually stored in a world-readable file to ease repeated entry of passphrase constraints. In lieu of a master passphrase, a master SSH key can also be used if there is a reachable, running SSH agent currently holding this key and if the key type is supported. (See ["SSH KEY SUITABILITY"](#ssh-key-suitability) and ["BUGS"](#bugs) below.) This too is compatible with vault(1). ## OPTIONS ### Passphrase generation The passphrase generation options can be divided into "passphrase source" options (`--phrase`, `--key`) and "passphrase constraint" options (all others). The passphrase source options are mutually exclusive --- you may only specify one of them --- while the passphrase constraint options may be combined in any way. The SERVICE is mandatory (see synopsis #1), unless the `--config` option is specified (see synopsis #2). All character constraints refer to ASCII printable characters only (space (`U+0020`) to tilde (`U+007E`), excluding the grave accent (`U+0060`)). -p, --phrase : Prompt for a passphrase. See also ["Configuration"](#configuration) for how this interacts with a stored passphrase or SSH key. -k, --key : Select an SSH key. An SSH agent such as OpenSSH’s ssh-agent(1) or PuTTY’s pageant(1) must be running and accessible, and have the desired key loaded. The SSH key must also be suitable for this purpose; see ["SSH KEY SUITABILITY"](#ssh-key-suitability) for details. See also ["Configuration"](#configuration) for how this interacts with a stored passphrase or SSH key. -l n, --length n : Force the passphrase to have the length n. Defaults to the length 20 if not specified, or if explicitly specified as 0. -r n, --repeat n : Permit only runs of up to n consecutive occurrences of the same character. Alternatively, forbid immediate additional repetitions of length n (or more) for any character in the derived passphrase. Setting n = `0` disables repetition constraints, which is the default. --lower n : Include at least n lowercase characters in the derived passphrase. Setting n = `0` forbids these characters entirely. The default is to not constrain the occurrences in any manner. --upper n : Include at least n uppercase characters in the derived passphrase. Setting n = `0` forbids these characters entirely. The default is to not constrain the occurrences in any manner. --number n : Include at least n digits in the derived passphrase. Setting n = `0` forbids these characters entirely. The default is to not constrain the occurrences in any manner. --space n : Include at least n spaces in the derived passphrase. Setting n = `0` forbids these characters entirely. The default is to not constrain the occurrences in any manner. --dash n : Include at least n "dashes" (`-` or `_`) in the derived passphrase. Setting n = `0` forbids these characters entirely. The default is to not constrain the occurrences in any manner. --symbol n : Include at least n symbols (any of `!"#$%&'()*+,./:;<=>?@[\]^{|}~-_`) in the derived passphrase. Setting n = `0` forbids these characters entirely, effectively also implying `--dash 0`. The default is to not constrain the occurrences in any manner. ### Configuration The configuration options directly modify the stored settings: default settings, known services, and service-specific settings. They are mutually exclusive; you may only specify one of them. The SERVICE is mandatory for `--notes` and `--delete`, optional for `--config`, and forbidden for `--delete-globals` and `--clear` (see synopsis #2 and synopsis #3). -n, --notes : Spawn an editor to edit notes for SERVICE. Use the `VISUAL` or `EDITOR` environment variables to configure the spawned editor. -c, --config : Save the given settings for SERVICE (if given), or save the given settings as global default settings. See the ["Passphrase generation"](#passphrase-generation) and ["Compatibility and extension options"](#compatibility-and-extension-options) sections for other options compatible with `--config`. !!! danger Do **not** use the `--phrase` and `--config` options together. The configuration is assumed to *not contain sensitive contents*, and is *not encrypted*. -x, --delete : Delete all stored settings for SERVICE. --delete-globals : Delete all stored global default settings. -X, --clear : Delete all stored settings. ### Storage management The storage management options deal with importing and exporting the stored settings. They are mutually exclusive; you may only specify one of them. Using `-` as PATH for standard input/standard output is supported. -e PATH, --export PATH : Export all saved settings into file PATH. -i PATH, --import PATH : Import saved settings from file PATH. ### Compatibility and extension options By default, derivepassphrase vault behaves in a manner compatible with vault(1). The compatibility and extension options modify the behavior to enable additional functionality, or specifically to force compatibility. vault(1) supports none of these options, and behaves as if the option had not been given or had been left in its default state. --overwrite-existing / --merge-existing : When importing a configuration via `--import`, or configuring the settings via `--config`, overwrite or merge (default) the existing configuration. If overwriting the configuration, then the whole configuration (for `--import`) or the respective section (service-specific or global, for `--config`), will be written from scratch. If merging, then each section (service-specific or global, for `--import`) or each singular setting (for `--config`) will be overwritten, but other unaffected settings/sections will not. (vault(1) behaves as if `--merge-existing` were always given.) --unset setting : When configuring via `--config`, also unset the specified setting, where setting is one of the passphrase generation settings (phrase, key, lower, …). May be specified multiple times. Must not overlap with any of the settings being set afterwards. (vault(1) does not support this option.) --export-as \{ json | sh \} : When exporting the configuration via `--export`, export as JSON (default) or as a shell script in sh(1) format. The JSON format is compatible with vault(1). For the shell script format, see the ["SHELL SCRIPT EXPORT FORMAT"](#shell-script-export-format) section for details. (vault(1) behaves as if `--export-as json` were always given.) ### Other Options --version : Show the version and exit. -h, --help : Show a help message and exit. ## SHELL SCRIPT EXPORT FORMAT If the shell script export format is selected, the configuration will be exported as a POSIX sh(1) script, containing calls to derivepassphrase vault to reconstruct the current configuration from scratch. The script assumes a conforming sh(1), with support for "here" documents. !!! danger **Do not run these emitted shell scripts directly without double-checking their output first!** ## SSH KEY SUITABILITY An SSH key is suitable for use with derivepassphrase vault if the SSH agent guarantees that signatures produced with this key will be deterministic, given the same message to be signed. This is a property specific to the key type, and sometimes the agent used: * RSA, Ed25519 and Ed448 keys are always suitable. OpenSSH’s ssh-agent(1) supports only these keys as suitable keys. * DSA and ECDSA keys are suitable if the SSH agent supports deterministic DSA signatures, e.g. by implementing RFC 6979. PuTTY’s pageant(1) supports this, in addition to the always-suitable keys mentioned above. ## ENVIRONMENT `VISUAL`, `EDITOR` : derivepassphrase vault uses this editor to edit service notes when called with `--notes`. `VISUAL` has higher precedence than `EDITOR`. `DERIVEPASSPHRASE_PATH` : derivepassphrase stores its configuration files and data in this directory. Defaults to `~/.derivepassphrase`. ## FILES `$DERIVEPASSPHRASE_PATH/vault.json` : The stored configuration for derivepassphrase vault: the default passphrase generation settings, the known service names, and the service-specific settings. This file is not intended for the user to edit. ## SECURITY !!! danger * There is **no way** to retrieve the generated passphrases if the master passphrase, the SSH key, or the exact passphrase settings are lost, short of trying out all possible combinations. You are **strongly** advised to keep independent backups of the settings and the SSH key, if any. * The configuration is **not** encrypted, and you are **strongly** discouraged from using a stored passphrase. * You are **strongly** advised to avoid the (shell script) configuration export format if possible, and use the JSON format instead. If you *must* use the shell script format, then **always** validate the export before attempting to interpret or run it. ## EXAMPLES ??? example "`derivepassphrase vault --phrase email`" Prompt for a master passphrase, then generate a standard passphrase (length 20, no character or repetition constraints) for the "email" service. ??? example "`derivepassphrase vault --key --upper 9 --lower 9 example.com`" Select an SSH key from the available suitable SSH keys in the running SSH agent, then generate a passphrase for the `example.com` service using the previously selected SSH key. The passphrase will have (standard) length 20, and at least nine characters will be uppercase characters and at least another nine characters will be lowercase characters. ??? example "`derivepassphrase example.com vault --key --upper 9 --lower 9 --number 9`" Attempt to generate a passphrase as in the previous example. This example will error out, because the passphrase constraints require at least 27 characters and the standard passphrase length 20 cannot accomodate this. ??? example "`derivepassphrase --config vault --key --upper 9 --lower 9 --space 2`" After selecting an SSH key, configure the default settings to use exactly nine uppercase characters, nine lowercase characters, and two spaces for each generated passphrase. (The specific service settings, or the command-line invocation, can still override these settings.) ??? example "`derivepassphrase vault example.com`" Because of the previous setting, the generated passphrase for the `example.com` service will behave as if `--key --upper 9 --lower 9 --space 2` had been specified during invocation (with the SSH key already having been selected). In particular, it is neither necessary to specify `--phrase` or `--key` nor is it necessary to actually select an SSH key or to type in a master passphrase. ## DIAGNOSTICS The derivepassphrase vault utility exits 0 on success, and >0 if an error occurs. ### Fatal error messsages on standard error (`%s` indicates a variable part of the message.) ??? failure "`%s is mutually exclusive with %s.`" The two indicated options must not be used at the same time. ??? failure "`%s requires a SERVICE or --config.`" Using the indicated passphrase generation option requires the SERVICE argument or the `--config` option. ??? failure "`%s requires a SERVICE.`" Using the indicated option requires the SERVICE argument. ??? failure "`%s does not take a SERVICE argument.`" The indicated option must not be specified together with the SERVICE argument. ??? failure "`Cannot load vault settings: %s.`" There was a fatal problem loading the stored vault configuration data. Further details are contained in the variable part of the message. ??? failure "`Cannot store vault settings: %s.`" There was a fatal problem saving the vault configuration data. Further details are contained in the variable part of the message. ??? failure "`Cannot import vault settings: %s.`" There was a fatal problem loading the imported vault configuration data. Further details are contained in the variable part of the message. ??? failure "`Cannot export vault settings: %s.`" There was a fatal problem saving the exported vault configuration data. Further details are contained in the variable part of the message. ??? failure "`Cannot load user config: %s.`" There was a fatal problem loading the central user configuration file. Further details are contained in the variable part of the message. ??? failure "`The user configuration file is invalid.`" (Exactly what it says.) ??? failure "`No usable SSH keys were found`" The running SSH agent does not contain any suitable SSH keys. ??? failure "`No valid SSH key selected`" We requested that an SSH key be selected, but we got an invalid selection. ??? failure "`The requested SSH key is not loaded into the agent.`" The running SSH agent does not contain the necessary SSH key. ??? failure "`Cannot find any running SSH agent because SSH_AUTH_SOCK is not set.`" We require a running SSH agent, but cannot locate its communication channel, which is normally indicated by the `SSH_AUTH_SOCK` environment variable. ??? failure "`Cannot connect to an SSH agent because this Python version does not support UNIX domain sockets.`" This Python installation does not support the communication mechanism necessary to talk to SSH agents. ??? failure "`Cannot connect to the SSH agent: %s.`" We cannot connect to the SSH agent indicated by the `SSH_AUTH_SOCK` environment variable. Further details are contained in the variable part of the message. ??? failure "`The SSH agent failed to or refused to supply a list of loaded keys.`" The SSH agent---while responsive in principle---did not fulfill the request. ??? failure "`The SSH agent failed to or refused to issue a signature with the selected key, necessary for deriving a service passphrase.`" The SSH agent---while responsive in principle---failed to cooperate with deriving a service passphrase from the selected master SSH key. ??? failure "`The SSH agent contains no keys suitable for derivepassphrase.`" None of the keys loaded into the SSH agent (if any) are suitable for use with derivepassphrase vault. See the ["SSH KEY SUITABILITY"](#ssh-key-suitability) section for the requirements the SSH key and the SSH agent must fulfill to be suitable. ??? failure "`Error communicating with the SSH agent`" There was a system error communicating with the SSH agent. ??? failure "`Cannot understand the SSH agent's response because it violates the communication protocol.`" (Exactly what it says.) ??? failure "`Not saving any new notes: the user aborted the request.`" (Exactly what it says.) ??? failure "`Cannot update %s settings without actual settings.`" Using `--config` requires at least one of the `--phrase`, `--key`, `--length`, etc. options. ??? failure "`Attempted to unset and set %s at the same time.`" While handling `--config`, the same configuration setting was passed as an option and as an argument to `--unset`. ??? failure "`Generating a passphrase requires a SERVICE.`" (Exactly what it says.) ??? failure "`No passphrase or key was given in the configuration.`" derivepassphrase vault does not know whether to use a master SSH key or a master passphrase. ??? failure "`No passphrase was given: the user aborted the request.`" (Exactly what it says.) ??? failure "`No SSH key was selected: the user aborted the request.`" (Exactly what it says.) ### Non-fatal warning and info messages on standard error (`%s` indicates a variable part of the message.) ??? warning "`The %s passphrase is not %s-normalized.`" The indicated passphrase---as a Unicode string---is not properly normalized according to the preferred Unicode normalization form (as specified in the central configuration file). It is therefore possible that the passphrase---as a byte string---is not the same byte string as you expect it to be (even though it *looks* correct), and that the derived passphrases thus do not match their expected values either. Please double-check. ??? warning "`An empty SERVICE is not supported by vault(1).`" vault(1) does not support the empty string as a value for SERVICE; it will treat the SERVICE as missing. For compatibility, derivepassphrase vault will do the same. In particular, if the empty service is imported in a configuration via `--import`, then this service cannot be accessed via the derivepassphrase vault command-line. ??? warning "`Replacing invalid value %s for key %s with %s.`" When importing a configuration, the indicated invalid value has been replaced with the indicated replacement value. (The "interpretation" of the configuration doesn’t change). ??? warning "`Removing ineffective setting %s = %s.`" When importing a configuration, the indicated ineffective setting has been removed. (The "interpretation" of the configuration doesn’t change). ??? warning "`The service name %s contains an ASCII control character, which is not supported by our shell completion code.`" Because of limitations in the shell completion code, this specific service name will not be available as a suggestion in tab completion. (This *only* affects tab completion, not other functionality.) ??? warning "`Setting a %s passphrase is ineffective because a key is also set.`" The configuration (global or key-specific) contains both a stored master passphrase and an SSH key. The master passphrase will not take effect. ??? warning "`A subcommand will be required in v1.0.`" [Since v0.2.0, until v1.0.] This command now requires a subcommand. For compatibility, it currently defaults to "vault". ??? warning "`Using deprecated v0.1-style config file %s, instead of v0.2-style %s.`" [Since v0.2.0, until v1.0.] A configuration file has been renamed. derivepassphrase vault will attempt to rename the file itself (`Successfully migrated to %s.`), or complain if it cannot rename it (`Failed to migrate to %s: %s`). ## COMPATIBILITY ### With other software derivepassphrase vault is almost drop-in compatible with James Coglan’s vault(1), version 0.3.0 (including "storeroom" support), meaning that each tool supports the same file formats and command-line arguments/options as the other one. Exceptions: * vault(1) does not support the ["Compatibility and extension options"](#compatibility-and-extension-options) listed above. * derivepassphrase vault can import and generate configuration exports in the same format as vault(1), but it cannot natively read or write vault(1)'s configuration file (non-storeroom) or configuration directory (storeroom). (The sister command derivepassphrase-export(1) can read both these formats and export the contents.) ### Forward and backward compatibility * [Since v0.2.0.] In v1.0, the commands derivepassphrase and derivepassphrase export will require an explicit subcommand name. Both default to the subcommand vault. * [Since v0.2.0.] In v1.0, the configuration data file for the vault subcommand will be named `vault.json`, instead of `config.json`. * [Since v0.2.0, to be removed in v1.0.] An existing configuration data file `config.json` will be attempted to be renamed to `vault.json`. ## SEE ALSO [derivepassphrase(1)](derivepassphrase.1.md), [pageant(1)](https://www.chiark.greenend.org.uk/~sgtatham/putty/), [ssh-agent(1)](https://www.openssh.com/), [vault(1)](https://www.npmjs.com/package/vault "James Coglan's 'vault'"). ## AUTHOR [Marco Ricci](https://the13thletter.info) (`software` at `the13thletter` dot `info`) ## BUGS * The defaults are dictated by vault(1), necessitating the ["Compatibility and extension options"](#compatibility-and-extension-options). (WONTFIX.) * The Windows version does not support SSH keys because Python on Windows does not support the predominant type of inter-process communication used by SSH agents on Windows.