Pass and Passage
There are a few helper scripts that can be used to make pass and passage more convenient to use. These scripts are installed in the process of setting up dotfiles and can be found in the .local/bin directory.
pass-clone
The pass-clone script is a simple utility to clone or update the pass and passage repositories, which are used for managing password-store and passage directories, respectively.
To use the script, simply run the following command:
The script will perform the following actions:
- If the
passfeature is enabled: a. Check if the password-store directory exists. b. If it exists, prompt the user to remove the existing directory. c. If the user confirms, remove the directory. d. Clone thepassrepository to the password-store directory. - If the
passagefeature is enabled: a. Check if the passage directory exists. b. If it exists, prompt the user to remove the existing directory. c. If the user confirms, remove the directory. d. Clone thepassagerepository to the passage directory.
Note: For private repositories, GitHub authentication is required to clone or update them.
pass-init
The pass-init script is a utility for initializing and configuring the pass password manager. It sets up the necessary environment variables, initializes the pass storage directory, and configures the remote Git repository for synchronization.
To use the script, simply run the following command:
The script will perform the following actions:
- Check if the password-store directory and the
.gpg-idfile exist. - If the
.gpg-idfile doesn't exist or thePASSWORD_STORE_KEYenvironment variable is different from the one in the.gpg-idfile, initialize or reinitializepass. - If the Git repository is not initialized in the password-store directory, initialize it.
- If the remote Git repository is not set, set it to the
PASS_REPOenvironment variable. - If GitHub authentication is available, fetch and checkout the main branch, set the upstream, and pull the changes.
Note: Before running the script, ensure you have generated a GPG key and set the PASSWORD_STORE_KEY environment variable. Additionally, set the PASS_REPO environment variable to the remote pass repository URL. For private repositories, GitHub authentication is required.
passage-init
The passage-init script is a utility for initializing and configuring the passage password manager. It ensures passage is installed, sets up the necessary environment variables, initializes the passage storage directory, and configures the remote Git repository for synchronization.
To use the script, simply run the following command:
The script will perform the following actions:
- Check if
passageis installed; if not, clone thePASSAGE_SHARE_REPOand installpassage. - Check if the
AGE_KEY_FILEexists; if not, prompt the user to generate an age key usingage-keygen. - If the
PASSAGE_DIRdirectory doesn't exist, create it. - If the Git repository is not initialized in the
PASSAGE_DIR, initialize it. - If the remote Git repository is not set, set it to the
PASSAGE_REPOenvironment variable. - If GitHub authentication is available, fetch and checkout the main branch, set the upstream, and pull the changes.
Note: Before running the script, ensure you have generated an age key and set the AGE_KEY_FILE environment variable. Additionally, set the PASSAGE_REPO environment variable to the remote passage repository URL. For private repositories, GitHub authentication is required.
pass-insert
The pass-insert script is a utility for inserting or updating passwords in both pass and passage password managers. It checks whether the specified password entry exists in each manager, and if not, it inserts the provided password or prompts the user to enter one. If the entry exists, it updates the password if the provided password is different from the existing one.
To use the script, run the following command:
Arguments:
pass-name: The name of the password entry (required).password: The password to insert or update (optional).
The script performs the following actions:
- Checks if
passandpassageare installed and initialized. - If
passis installed and initialized, it checks whether the specifiedpass-nameexists in the password store. - If the entry exists and the provided password is different, it updates the password.
- If the entry doesn't exist, it inserts the provided password or prompts the user to enter one.
- If
passageis installed and initialized, it checks whether the specifiedpass-nameexists in the passage store. - If the entry exists and the provided password is different, it updates the password.
- If the entry doesn't exist, it inserts the provided password or prompts the user to enter one.
Note: Ensure that both pass and passage are installed and initialized before using the script. Also, set the AGE_KEY_FILE environment variable to the age key file path.
pass-rm
The pass-rm script is a utility for removing password entries from both pass and passage password managers. It checks whether the specified password entry exists in each manager, and if so, it removes the entry according to the provided options.
To use the script, run the following command:
Arguments:
--recursive, -r: Optional flag to remove a directory and its contents recursively.--force, -f: Optional flag to force the removal without confirmation.pass-name: The name of the password entry to remove (required).
The script performs the following actions:
- Parses options and extracts the
pass-name. - Checks if
passandpassageare installed. - If
passis installed, it checks whether the specifiedpass-nameexists in the password store. - If the entry exists, it removes the entry according to the provided options.
- If the entry doesn't exist, it logs an information message.
- If
passageis installed, it checks whether the specifiedpass-nameexists in the passage store. - If the entry exists, it removes the entry according to the provided options.
- If the entry doesn't exist, it logs an information message.
Note: Ensure that both pass and passage are installed before using the script.
pass-pull
The pass-pull script is a utility for pulling changes from remote repositories for both pass and passage password managers. It checks whether the password managers are initialized and have remote repositories set, and if so, it pulls the changes from the remote repositories.
To use the script, simply run the following command:
The script performs the following actions:
- Checks if GitHub is authenticated. If not, it logs an information message and exits.
- Checks if the
PASSWORD_STORE_DIRis set and has a.gpg-idfile forpass. - If the directory exists and has a remote repository set, it pulls changes from the remote repository.
- If the directory doesn't exist or the remote is not set, it logs an information message.
- Checks if the
PASSAGE_DIRis set and has theAGE_KEY_FILEforpassage. - If the directory exists and has a remote repository set, it pulls changes from the remote repository.
- If the directory doesn't exist or the remote is not set, it logs an information message.
Note: Ensure that you have authenticated with GitHub and both pass and passage are initialized before using the script.
pass-push
The pass-push script is a utility for committing and pushing changes to remote repositories for both pass and passage password managers. It checks whether the password managers are initialized and have remote repositories set, and if so, it commits and pushes the changes to the remote repositories.
To use the script, simply run the following command:
The script performs the following actions:
- Checks if the
PASSWORD_STORE_DIRis set and has a.gpg-idfile forpass. - If the directory exists and has a remote repository set, it commits changes and pushes them to the remote repository.
- If the directory doesn't exist or the remote is not set, it logs an information message.
- Checks if the
PASSAGE_DIRis set and has theAGE_KEY_FILEforpassage. - If the directory exists and has a remote repository set, it commits changes and pushes them to the remote repository.
- If the directory doesn't exist or the remote is not set, it logs an information message.
Note: Ensure that both pass and passage are initialized before using the script.
pass-sync
The pass-sync script is a utility for synchronizing passwords between the pass and passage password managers. It checks whether both password managers are initialized and then performs a bidirectional sync between them.
To use the script, simply run the following command:
The script performs the following actions:
- Checks if the
PASSWORD_STORE_DIRis set and has a.gpg-idfile forpass. If not, it logs an information message and exits. - Checks if the
PASSAGE_DIRis set and has theAGE_KEY_FILEforpassage. If not, it logs an information message and exits. - Syncs from
passtopassage: - Iterates through all password entries in the
passpassword store. - If an entry does not exist in the
passagestore, it inserts the entry into thepassagestore. - Syncs from
passagetopass: - Iterates through all password entries in the
passagepassword store. - If an entry does not exist in the
passstore, it inserts the entry into thepassstore.
Note: Ensure that both pass and passage are initialized before using the script.