First commit
This commit is contained in:
commit
70c3333481
19
README.txt
Normal file
19
README.txt
Normal file
@ -0,0 +1,19 @@
|
||||
DESCRIPTION:
|
||||
A simple bash script to assist with migrating your password store betweeen systems with different gpg keys that use the 'pass' password managed.
|
||||
Can be used to export all of the passwords into a plaintext file from your password store.
|
||||
Alternatively has the ability to take a path of the plaintext exported file and import it into an existing password store.
|
||||
|
||||
NOTE:
|
||||
There are a few caveats. This won't work if:
|
||||
- The file you import should be in the same format as the one that this tool exports as.
|
||||
- Your actual passwords contain a whitespace ' '.
|
||||
- Your password names have a '.' symbol in their names, ex:
|
||||
The below will fail
|
||||
/.pass/pass/pass
|
||||
/pass/.pass/pass
|
||||
/pass/pass/.pass
|
||||
The below will succeed
|
||||
/pass/pass/pass
|
||||
|
||||
AUTHOR:
|
||||
96-fromsofia - 2A9-7CC@96-fromsofia.net || June 2022
|
||||
51
pass-migrate.sh
Executable file
51
pass-migrate.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Prompt to select an option
|
||||
echo -e "Please select the action you want to perform.\nAllowed options are:\n[import|export]\n"
|
||||
read -a option
|
||||
|
||||
## EXPORTING
|
||||
if [[ "$option" == "export" ]]
|
||||
then
|
||||
# Locate the password store
|
||||
if [ -z $PASSWORD_STORE_DIR ]
|
||||
then
|
||||
cd ~/.password-store
|
||||
else
|
||||
cd $(echo $PASSWORD_STORE_DIR)
|
||||
fi
|
||||
|
||||
# File to save the exported contents to
|
||||
touch ~/.exported-passwords.txt
|
||||
echo -e "Your passwords will be saved to ~/.exported-passwords.txt\nPlease wait..\n"
|
||||
|
||||
# Export logic
|
||||
for psw in $(find . -type f -name "*.gpg" | awk -F. '{print $2}' | tr '\n' ' ' ; echo);
|
||||
do
|
||||
echo -e "$psw $(pass $psw)" >> ~/.exported-passwords.txt
|
||||
done
|
||||
echo -e "Your passwords have been exported!\nYou can now restart the script with the import function to restore them into your new device.\n"
|
||||
|
||||
## IMPORTING
|
||||
elif [[ "$option" == "import" ]]
|
||||
then
|
||||
# Get the location of the file to import
|
||||
echo -e "Provide the full path of the file you wish to import:\n"
|
||||
read -a psw_import
|
||||
|
||||
# Generate 2 separate files, one for names and one for passwords
|
||||
echo -e "Importing passwords.\nPlease wait..\n"
|
||||
|
||||
# Importing logic
|
||||
|
||||
while IFS= read -r line; do
|
||||
name=$(printf '%s\n' "$line" | awk '{print $1}')
|
||||
new_psw=$(printf '%s\n' "$line" | awk '{print $2}')
|
||||
printf "%s\n%s\n" "$new_psw" "$new_psw" | pass insert $name
|
||||
done < "$psw_import"
|
||||
echo -e "Your passwords have been imported!\nThis script will now exit.\n"
|
||||
|
||||
## INVALID, EXIT
|
||||
else
|
||||
echo -e "Unknown action specified!!\nExiting..\n"
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user