Skip to content

Instantly share code, notes, and snippets.

@p1-ra
Created December 5, 2022 15:41
Show Gist options
  • Save p1-ra/ce234b0bb19b7551dbbb951f767c24de to your computer and use it in GitHub Desktop.
Save p1-ra/ce234b0bb19b7551dbbb951f767c24de to your computer and use it in GitHub Desktop.
Re-cipher pass password-store
recipher_store() {
store_path="$1";
gpg_recipients="";
if [ ! -f "${store_path}/.gpg-id" ]; then
echo "invalid password-store path"
return 1
fi
for id in $(cat "${store_path}/.gpg-id"); do
gpg_recipients="${gpg_recipients} -r ${id}";
done
for f in $(find "${store_path}" -iname '*.gpg'); do
clear_file=$(mktemp);
gpg -d "${f}" > "${clear_file}";
eval "gpg -e ${gpg_recipients} ${clear_file}";
mv "${clear_file}.gpg" "${f}"
rm "${clear_file}" || "[/!\] Failed to rm secret ${clear_file}";
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment