Created
December 5, 2022 15:41
-
-
Save p1-ra/ce234b0bb19b7551dbbb951f767c24de to your computer and use it in GitHub Desktop.
Re-cipher pass password-store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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