DEV Community

Fernando Tricas García
Fernando Tricas García

Posted on • Edited on

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

Update (2023-09-27): another approach is to use git to download your data from your backup repo. This is for using a passwords database available in another machine, it is not related to keepass. In this case the only problems are:

  • Setting up the repo in your pass database
pass git init
pass git remote add origin <url>
pass git add -A
pass git commit -m "initial commit"
pass git push -u origin master
Enter fullscreen mode Exit fullscreen mode
  • Exporting your gpg keys (because the data is encrypted with them).
gpg --export-secret-keys $ID > my-private-key.asc
Enter fullscreen mode Exit fullscreen mode

You may need:

gpg --list-secret-keys
Enter fullscreen mode Exit fullscreen mode
  • Importing them in the new place.
gpg --import my-private-key.asc
Enter fullscreen mode Exit fullscreen mode
  • Cloning the repo with the passwords:
git clone <url> ~/.password-store/
Enter fullscreen mode Exit fullscreen mode

This info is from: How to backup passwords from pass

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 password 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

Top comments (0)