pass(1) to BitWarden/Vaultwarden CSV exporter.
Find a file
Rupus Reinefjord 6a6c49fdc8
Merge pull request #4 from stonewareslord/master
Add support for KeePassXC import; Many misc improvements
2018-08-16 11:31:42 +02:00
.gitignore Ignore pass.csv 2018-08-15 00:49:09 -04:00
LICENSE Initial commit 2016-05-30 00:54:42 +02:00
pass2csv.py Set +x bit for pass2csv.py 2018-08-15 01:09:36 -04:00
README.md Note python3 requirement 2018-08-15 00:59:11 -04:00

pass2csv

Needs python-gnupg and python3. Run with path to password store as argument:

python3 -m pip install --user python-gnupg
python3 pass2csv.py ~/.password-store

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.

    To enable, set KPX_FORMAT=False in pass2csv.py

  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 LOGIN_FIELDS, URL is extracted if GET_URL is set, and 'Notes' contains any other fields that do not match EXCLUDE_ROWS.

    To enable, set KPX_FORMAT=True and configure the variables mentioned above in pass2csv.py.

    'User' field is chosen by searching for the first field with a name in LOGIN_FIELDS. Once the field is found, the login is set and the field is removed from notes.

Example KeePassXC Import

  • Variable definitions (pass2csv.py)

      KPX_FORMAT=True
    
      LOGIN_FIELDS=['username', 'login', 'email']
      GET_URL=True
      EXCLUDE_ROWS=['^---$']
    
  • 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 filled entry in LOGIN_FIELDS.

  • 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 in EXCLUDE_ROWS.

Example KeePass Generic CSV Importer

  • Variable definitions (pass2csv.py)

      KPX_FORMAT=False
    
  • Password entry: Same as above

  • Output CSV row (formatted)

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