DEV Community

loading...

So, you want to move your keepass database to pass?

fernand0 profile image Fernando Tricas García Updated on ・1 min read

Update (2021-02-12): the script did not work well, it was missing the username field from keepass.

First, you'll need to create a gpg key if you do not have one:

gpg --gen-key

Then you can init your pass respository (with git, in our case):

pass init user

Put it under git control:

pass git init

Now you could add a password with:

pass insert test

It will ask you for the passord and you can see it added with:

pass

Nevertheless, my objective was to import to this new database the keepass database. For this, you can open the keepass program and export the database as a .csv.
Since keepass will put quotes (") for each field and if your names and passwords do not contain them, you can delete them to simplify the importing program (with your prefered editor, for example).

Then, you can run the program:

./keepassToPass.sh yourPassFile.csv

#!/bin/sh

if [ $# -eq 0 ]
then
    echo "You must provide a file name"
    exit
fi

while IFS=, read -r f1 f2 f3 f4 f5 f6 f7 f8 ; 
do   
    echo "Creating pass entry for $f1 $f2"; 
    echo "$f4" | pass insert -e "$f1/$f2" 
    sleep 1

done < "$1"
Enter fullscreen mode Exit fullscreen mode

You can download (no guarantee) from keepassToPass.sh

References:

Introducing pass

Discussion (0)

pic
Editor guide