Skip to main content

Export pass(1), "the standard unix password manager", to CSV

Project description

pass2csv

Source is available at GitHub.

You can install it directly from PyPI with pip:

python3 -m pip install --user pass2csv

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 ...]
                        regexps to exclude from the notes field (only used with -x)

Export format

There are two ways to export CSV data:

  1. The format for the KeePass Generic CSV Importer:

    Group(/),Title,Password,Notes
    

    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.

    This is the default mode.

  2. The format for the KeePassXC Importer:

    Group(/),Title,Login,Password,URL,Notes
    

    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.

    '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.

    Use -x or --kpx to enable this mode.

Example KeePassXC Import

  • Cmd line

      pass2csv ~/.password-store -x -l username login email -u -e '^---$'
    
  • 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"
    
  • 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.

Example KeePass Generic CSV Importer

  • Cmd line

      pass2csv ~/.password-store
    
  • Password entry: Same as above

  • Output CSV row (formatted)

      sites, example, password123, "---\nusername: user_name\nemail: user@example.com\nurl: example.com\nsome_note"
    

Development

Create a virtual environment:

python3 -m venv venv

Activate the environment:

. venv/bin/activate

Now you may either use pip directly to install the dependencies, or you can install pip-tools. The latter is recommended.

pip

pip install -r requirements.txt

pip-tools

pip-tools can keep your virtual environment in sync with the requirements.txt file, as well as compiling a new requirements.txt when adding/removing a dependency in requirements.in.

It is recommended that pip-tools is installed within the virutal environment.

pip install pip-tools
pip-compile  # only necessary when adding/removing a dependency
pip-sync

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pass2csv-0.1.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file pass2csv-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pass2csv-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for pass2csv-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1465ea7a6d8fc25d24c9992a8e9b917d2f2d6d991741e372bb805e3f355fc3a3
MD5 a1b9fbe1c13edd3da7418bf397ef2816
BLAKE2b-256 607d658b98fbff73fba20457d849662cb666e3719cf539d658748dff1da1caca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page