Skip to content

Instantly share code, notes, and snippets.

@enblanco
Last active December 29, 2020 08:38
Show Gist options
  • Save enblanco/3d4b30162b2e63116f44a1208d79fe9b to your computer and use it in GitHub Desktop.
Save enblanco/3d4b30162b2e63116f44a1208d79fe9b to your computer and use it in GitHub Desktop.
Export passwords from the `pass` password manager

Export passwords from the pass password manager

You can do this if you are running gpg-agent (and your passphrase is loaded). 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

#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment