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
pass
feature 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 thepass
repository to the password-store directory. - If the
passage
feature 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 thepassage
repository 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-id
file exist. - If the
.gpg-id
file doesn't exist or thePASSWORD_STORE_KEY
environment variable is different from the one in the.gpg-id
file, 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_REPO
environment 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
passage
is installed; if not, clone thePASSAGE_SHARE_REPO
and installpassage
. - Check if the
AGE_KEY_FILE
exists; if not, prompt the user to generate an age key usingage-keygen
. - If the
PASSAGE_DIR
directory 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_REPO
environment 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
pass
andpassage
are installed and initialized. - If
pass
is installed and initialized, it checks whether the specifiedpass-name
exists 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
passage
is installed and initialized, it checks whether the specifiedpass-name
exists 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
pass
andpassage
are installed. - If
pass
is installed, it checks whether the specifiedpass-name
exists 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
passage
is installed, it checks whether the specifiedpass-name
exists 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_DIR
is set and has a.gpg-id
file 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_DIR
is set and has theAGE_KEY_FILE
forpassage
. - 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_DIR
is set and has a.gpg-id
file 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_DIR
is set and has theAGE_KEY_FILE
forpassage
. - 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_DIR
is set and has a.gpg-id
file forpass
. If not, it logs an information message and exits. - Checks if the
PASSAGE_DIR
is set and has theAGE_KEY_FILE
forpassage
. If not, it logs an information message and exits. - Syncs from
pass
topassage
: - Iterates through all password entries in the
pass
password store. - If an entry does not exist in the
passage
store, it inserts the entry into thepassage
store. - Syncs from
passage
topass
: - Iterates through all password entries in the
passage
password store. - If an entry does not exist in the
pass
store, it inserts the entry into thepass
store.
Note: Ensure that both pass
and passage
are initialized before using the script.