9

I've been using the pass password manager for a year or so now, and it's awesome, but sometimes I like to test other password managers and then I need my passwords back.

So far I've just been adding them manually as I need them, but if I want to migrate to another password manager I need a script, because I don't have the patience to do it one by one, considering I have near to a hundred (if not more).

Is it possible? Is there already a solution?

I've searched for a solution on and off for the past couple months and haven't been able to find one where it's "just run this script and boom exported".

Is there such a script? If not, what or where should I look into to make one?

  • @josten Yeah I'm thinking have something where it just goes through every file and it it gets the password and saves that somewhere. That's one way to do it. But not sure how... – greduan Nov 29 '14 at 0:14
9

You can do this if you are running gpg-agent (and your passphrase is loaded), by looping through the files in your password store and writing them to a separate file.

You do have to strip the leading directories from the path ($PASSWORD_STORE_DIR) and the .gpg extension from each of the files in the subdirectories, but otherwise it is straightforward enough:

#!/usr/bin/env bash
# export passwords to external file

shopt -s nullglob globstar
prefix=${PASSWORD_STORE_DIR:-$HOME/.password-store}

for file in "$prefix"/**/*.gpg; do                           
    file="${file/$prefix//}"
    printf "%s\n" "Name: ${file%.*}" >> exported_passes
    pass "${file%.*}" >> exported_passes
    printf "\n\n" >> exported_passes
done
  • That is certainly very simple, along the lines of what I was thinking. :) Just real quick, how would you add the filename before each file's content and then two lines between each file (for separation)? I'm not extremely familiar with shell scripting. – greduan Nov 29 '14 at 18:42
  • BTW the reason I want that is because some passwords (namely those that weren't imported from LastPass) have no information about them besides the password itself, so when there are a lot of those I dunno what it is a password for. – greduan Nov 29 '14 at 19:17
  • @Greduan Updated to print in the format you asked about. – jasonwryan Nov 29 '14 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.