2016-05-29 19:00:21 -04:00
|
|
|
# pass2csv
|
2020-06-07 16:39:28 -04:00
|
|
|
Requires [python-gnupg](https://pypi.python.org/pypi/python-gnupg) and python3.
|
2018-08-15 00:59:11 -04:00
|
|
|
Run with path to password store as argument:
|
|
|
|
|
|
|
|
```
|
|
|
|
python3 -m pip install --user python-gnupg
|
|
|
|
python3 pass2csv.py ~/.password-store
|
|
|
|
```
|
2016-05-30 05:31:00 -04:00
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```
|
|
|
|
$ pass2csv --help
|
|
|
|
usage: pass2csv.py [-h] [-a] [-b GPGBINARY] [-x] [-l LOGIN_FIELDS [LOGIN_FIELDS ...]] [-u]
|
|
|
|
[-e EXCLUDE_ROWS [EXCLUDE_ROWS ...]]
|
|
|
|
path
|
|
|
|
|
|
|
|
positional arguments:
|
|
|
|
path path to the password-store folder to export
|
|
|
|
|
|
|
|
optional arguments:
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
-a, --agent ask gpg to use its auth agent
|
|
|
|
-b GPGBINARY, --gpgbinary GPGBINARY
|
|
|
|
path to the gpg binary you wish to use
|
|
|
|
-x, --kpx format the CSV for KeePassXC
|
|
|
|
-l LOGIN_FIELDS [LOGIN_FIELDS ...], --login-fields LOGIN_FIELDS [LOGIN_FIELDS ...]
|
|
|
|
strings to interpret as names of login fields (only used with -x)
|
|
|
|
-u, --get-url match row starting with 'url:' and extract it (only used with -x)
|
|
|
|
-e EXCLUDE_ROWS [EXCLUDE_ROWS ...], --exclude-rows EXCLUDE_ROWS [EXCLUDE_ROWS ...]
|
|
|
|
regexp strings to exclude from the notes field (only used with -x)
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Export format
|
2018-08-15 00:48:57 -04:00
|
|
|
There are two ways to export CSV data:
|
2016-05-30 05:31:00 -04:00
|
|
|
|
2018-08-15 00:48:57 -04:00
|
|
|
1. The format for the KeePass Generic CSV Importer:
|
2016-05-30 05:31:00 -04:00
|
|
|
|
2018-08-15 00:48:57 -04:00
|
|
|
Group(/),Title,Password,Notes
|
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
Where 'Password' is the first line of the entry in `pass` and
|
|
|
|
'Notes' are all subsequent lines. '\\' should not be interpreted as
|
|
|
|
an escape character.
|
2018-08-15 00:48:57 -04:00
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
This is the default mode.
|
2018-08-15 00:48:57 -04:00
|
|
|
|
|
|
|
2. The format for the KeePassXC Importer:
|
|
|
|
|
|
|
|
Group(/),Title,Login,Password,URL,Notes
|
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
Where 'Password' is the first line of the entry in `pass`, 'User' is
|
|
|
|
configured with `-l`, URL is extracted if `-u` is
|
|
|
|
set, and 'Notes' contains any other fields that do not match
|
|
|
|
`-e`.
|
2018-08-15 00:48:57 -04:00
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
'User' field is chosen by searching for the first field with a name
|
|
|
|
set by `-l`. Once the field is found, the login is set and the field
|
|
|
|
is removed from notes.
|
2018-08-15 00:48:57 -04:00
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
Use `-x` or `--kpx` to enable this mode.
|
2018-08-15 00:48:57 -04:00
|
|
|
|
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
### Example KeePassXC Import
|
|
|
|
- Cmd line
|
2018-08-15 00:48:57 -04:00
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
pass2csv ~/.password-store -x -l username login email -u -e '^---$'
|
2018-08-15 00:48:57 -04:00
|
|
|
|
|
|
|
- Password entry (`sites/example`)
|
|
|
|
|
|
|
|
password123
|
|
|
|
---
|
|
|
|
username: user_name
|
|
|
|
email: user@example.com
|
|
|
|
url: example.com
|
|
|
|
some_note
|
|
|
|
|
|
|
|
- Output CSV row (formatted)
|
|
|
|
|
|
|
|
sites, example, user_name, password123, example.com, "email: user@example.com\nsome_note"
|
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
- `user_name` was chosen because `username` was the first argument to `-l`.
|
|
|
|
- Both logn and URL fields were excluded from the notes field because they
|
|
|
|
were used in another field.
|
|
|
|
- `---` Was not included in the notes field because it was matched by `-e`.
|
2018-08-15 00:48:57 -04:00
|
|
|
|
|
|
|
### Example KeePass Generic CSV Importer
|
2020-06-07 16:39:28 -04:00
|
|
|
- Cmd line
|
2018-08-15 00:48:57 -04:00
|
|
|
|
2020-06-07 16:39:28 -04:00
|
|
|
pass2csv ~/.password-store
|
2018-08-15 00:48:57 -04:00
|
|
|
|
|
|
|
- Password entry: Same as above
|
|
|
|
- Output CSV row (formatted)
|
|
|
|
|
|
|
|
sites, example, password123, "---\nusername: user_name\nemail: user@example.com\nurl: example.com\nsome_note"
|