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:
-
The format for the KeePass Generic CSV Importer:
Group(/),Title,Password,NotesWhere 'Password' is the first line of the entry in
passand 'Notes' are all subsequent lines. '\' should not be interpreted as an escape character.To enable, set
KPX_FORMAT=Falseinpass2csv.py -
The format for the KeePassXC Importer:
Group(/),Title,Login,Password,URL,NotesWhere 'Password' is the first line of the entry in
pass, 'User' is configured withLOGIN_FIELDS, URL is extracted ifGET_URLis set, and 'Notes' contains any other fields that do not matchEXCLUDE_ROWS.To enable, set
KPX_FORMAT=Trueand configure the variables mentioned above inpass2csv.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.
-
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: [email protected] url: example.com some_note -
Output CSV row (formatted)
sites, example, user_name, password123, example.com, "email: [email protected]\nsome_note" -
user_namewas chosen becauseusernamewas the first filled entry inLOGIN_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 inEXCLUDE_ROWS.
-
Variable definitions (
pass2csv.py)KPX_FORMAT=False -
Password entry: Same as above
-
Output CSV row (formatted)
sites, example, password123, "---\nusername: user_name\nemail: [email protected]\nurl: example.com\nsome_note"