pash/README.md

208 lines
5.8 KiB
Markdown
Raw Permalink Normal View History

2019-02-24 14:48:54 -06:00
# pash
2019-11-26 06:21:45 -06:00
A simple password manager using GPG written in POSIX `sh`.
2019-02-24 14:48:54 -06:00
2019-11-30 13:51:42 -06:00
- Written in safe and [shellcheck](https://www.shellcheck.net/) compliant POSIX `sh`.
- Only `120~` LOC (*minus blank lines and comments*).
- Compatible with `pass`'s password store.
- Clears the clipboard after a timeout.
- Configurable password generation using `/dev/urandom`.
2019-11-30 15:47:53 -06:00
- Guards against `set -x`, `ps` and `/proc` leakage.
2019-11-30 13:51:42 -06:00
- Easily extendible through the shell.
2019-02-25 14:31:28 -06:00
2019-02-25 00:55:10 -06:00
## Table of Contents
2019-02-25 00:54:14 -06:00
<!-- vim-markdown-toc GFM -->
* [Dependencies](#dependencies)
* [Usage](#usage)
* [FAQ](#faq)
2019-02-26 12:22:55 -06:00
* [How does this differ from `pass` or etc?](#how-does-this-differ-from-pass-or-etc)
2019-02-25 00:54:32 -06:00
* [Where are passwords stored?](#where-are-passwords-stored)
2019-11-08 06:48:13 -06:00
* [How can I use a public key?](#how-can-i-use-a-public-key)
2019-11-30 13:53:15 -06:00
* [How do I change the password length?](#how-do-i-change-the-password-length)
* [How do I change the password generation pattern?](#how-do-i-change-the-password-generation-pattern)
2019-11-08 07:05:49 -06:00
* [How do I change the password store location?](#how-do-i-change-the-password-store-location)
2019-11-28 12:38:37 -06:00
* [How do I change the clipboard tool?](#how-do-i-change-the-clipboard-tool)
2019-11-30 04:19:32 -06:00
* [How do I change the clipboard timeout?](#how-do-i-change-the-clipboard-timeout)
2019-11-29 15:23:02 -06:00
* [How do I rename an entry?](#how-do-i-rename-an-entry)
2019-11-29 12:01:44 -06:00
* [How can I migrate from `pass` to `pash`?](#how-can-i-migrate-from-pass-to-pash)
2019-11-29 15:23:02 -06:00
* [How can I extend `pash`?](#how-can-i-extend-pash)
2019-02-25 00:54:14 -06:00
<!-- vim-markdown-toc -->
2019-02-24 16:04:26 -06:00
## Dependencies
2019-02-25 01:04:16 -06:00
- `gpg` or `gpg2`
2019-02-24 16:04:26 -06:00
2019-02-25 00:48:54 -06:00
**Clipboard Support**:
2019-11-28 12:33:09 -06:00
- `xclip` (*can be customized through `PASH_CLIP`*).
2019-11-26 06:21:45 -06:00
2019-02-24 16:04:26 -06:00
## Usage
2019-05-22 13:58:56 -05:00
Examples: `pash add web/gmail`, `pash list`, `pash del google`, `pash show github`, `pash copy github`.
2019-02-24 16:04:26 -06:00
```
2019-02-25 00:48:54 -06:00
SYNOPSIS
2019-05-22 13:58:56 -05:00
pash [ add|del|show|list|copy ] [name]
2019-02-25 00:48:54 -06:00
COMMANDS
2019-05-22 13:58:56 -05:00
[a]dd [name] - Create a new password entry.
[c]opy [name] - Copy entry to the clipboard.
[d]el [name] - Delete a password entry.
[l]ist - List all entries.
[s]how [name] - Show password for an entry.
2019-11-30 09:00:57 -06:00
[t]ree - List all entries in a tree.
2019-11-29 14:17:28 -06:00
OPTIONS
2019-11-30 04:19:32 -06:00
Using a key pair: export PASH_KEYID=XXXXXXXX
Password length: export PASH_LENGTH=50
Password pattern: export PASH_PATTERN=_A-Z-a-z-0-9
Store location: export PASH_DIR=~/.local/share/pash
2019-11-30 05:09:14 -06:00
Clipboard tool: export PASH_CLIP='xclip -sel c'
2019-11-30 05:41:28 -06:00
Clipboard timeout: export PASH_TIMEOUT=15 ('off' to disable)
2019-02-24 16:04:26 -06:00
```
2019-02-25 00:53:48 -06:00
## FAQ
2019-02-26 12:22:55 -06:00
### How does this differ from `pass` or etc?
2019-11-29 09:32:28 -06:00
I was looking for a CLI password manager (*written in shell*) and wasn't happy with the options I had found. They either had multiple instances of `eval` (*on user inputted data*), lots of unsafe shell (*nowhere near being `shellcheck` compliant.*) or they were overly complex. The opposites for what I'd want in a password manager.
2019-02-26 12:22:55 -06:00
2019-11-30 12:14:52 -06:00
I decided to write my own. `pash` is written in POSIX `sh` and the codebase is minimal (*120~ LOC minus blank lines and comments*).
2019-02-26 12:22:55 -06:00
2019-02-25 00:54:32 -06:00
### Where are passwords stored?
2019-02-25 00:53:48 -06:00
2019-11-10 16:50:16 -06:00
The passwords are stored in GPG encrypted files located at `${XDG_DATA_HOME:=$HOME/.local/share}/pash}`.
2019-02-25 00:53:48 -06:00
2019-11-08 06:48:13 -06:00
### How can I use a public key?
2019-02-24 14:48:54 -06:00
2019-11-08 06:48:13 -06:00
Set the environment variable `PASH_KEYID` to the ID of the key you'd like to encrypt and decrypt passwords with.
Example:
```sh
2019-11-08 07:05:49 -06:00
# Default: 'unset'.
2019-11-08 06:51:07 -06:00
export PASH_KEYID=XXXXXXXX
2019-11-08 06:48:13 -06:00
# This can also be an email.
export PASH_KEYID=dylan.araps@gmail.com
2019-11-08 07:05:49 -06:00
# This can also be used as a one-off.
PASH_KEYID=XXXXXXXX pash add github
```
2019-11-30 13:53:15 -06:00
### How do I change the password length?
2019-11-08 07:05:49 -06:00
Set the environment variable `PASH_LENGTH` to a valid integer.
Example:
```sh
# Default: '50'.
export PASH_LENGTH=50
# This can also be used as a one-off.
PASH_LENGTH=10 pash add github
```
2019-11-30 13:53:15 -06:00
### How do I change the password generation pattern?
Set the environment variable `PASH_PATTERN` to a valid `tr` string.
```sh
# Default: '_A-Z-a-z-0-9'.
export PASH_PATTERN=_A-Z-a-z-0-9
# This can also be used as a one-off.
PASH_PATTERN=_A-Z-a-z-0-9 pash add hackernews
```
2019-11-08 07:05:49 -06:00
### How do I change the password store location?
Set the environment variable `PASH_DIR` to a directory.
```sh
# Default: '~/.local/share/pash'.
export PASH_DIR=~/.local/share/pash
# This can also be used as a one-off.
PASH_DIR=/mnt/drive/pash pash list
2019-11-08 06:48:13 -06:00
```
2019-11-10 16:49:31 -06:00
2019-11-28 12:38:37 -06:00
### How do I change the clipboard tool?
Set the environment variable `PASH_CLIP` to a command.
2019-11-30 12:54:17 -06:00
**NOTE**: I advise that you disable clipboard history in managers like KDE's `klipper` before copying passwords through `pash`. Your Desktop Environment's clipboard manager may read entries from the X clipboard when `xclip` is used.
**NOTE**: `pash` will correctly clear all clipboards which have history disabled.
```sh
2019-11-30 05:09:14 -06:00
# Default: 'xclip -sel c'.
export PASH_CLIP='xclip -sel c'
2019-11-29 15:23:02 -06:00
# This can also be used as a one-off.
2019-11-30 05:09:14 -06:00
PASH_CLIP='xclip -sel c' pash copy github
```
2019-11-29 12:01:44 -06:00
2019-11-30 04:19:32 -06:00
### How do I change the clipboard timeout?
Set the environment variable `PASH_TIMEOUT` to a valid `sleep` interval or `off` to disable the feature.
2019-11-30 04:19:32 -06:00
```sh
2019-11-30 05:41:28 -06:00
# Default: '15'
export PASH_TIMEOUT=15
2019-11-30 04:19:32 -06:00
# Disable timeout.
export PASH_TIMEOUT=off
2019-11-30 04:19:32 -06:00
# This can also be used as a one-off.
PASH_TIMEOUT=5 pash copy github
```
2019-11-29 15:23:02 -06:00
### How do I rename an entry?
It's a file! Standard UNIX utilities can be used here.
2019-11-29 12:01:44 -06:00
### How can I migrate from `pass` to `pash`?
2019-11-29 15:35:46 -06:00
I cannot guarantee 100% compatibility with the stores from `pass` as `pash` wasn't written as a 1:1 replacement, however users have reported that `pash` does in fact work fine with `pass`' store.
2019-11-29 12:01:44 -06:00
Add the following to your `.shellrc` or `.profile`.
```
read -r PASH_KEYID < "$PASH_DIR/.gpg-id"
export PASH_DIR=${PASSWORD_STORE_DIR:-$HOME/.password-store}
export PASH_KEYID
```
2019-11-29 15:23:02 -06:00
### How can I extend `pash`?
A shell function can be used to add new commands and functionality to `pash`. The following example adds `pash git` to execute `git` commands on the password store.
```sh
pash() {
case $1 in
g*)
cd "${PASH_DIR:=${XDG_DATA_HOME:=$HOME/.local/share}/pash}"
shift
git "$@"
;;
*)
command pash "$@"
;;
esac
}
```