pass, also known as the Unix password store, is a simple, command-line-driven password manager that follows the Unix philosophy. It stores passwords in GPG-encrypted files, organized in a simple directory tree, and can be easily synchronized using Git. This guide will walk you through setting up pass, generating GPG keys, managing your passwords, and integrating it with Git for secure and version-controlled password management.
To install pass on Debian-based systems (like Ubuntu):
1# debian
2sudo apt install pass
3
4# arch
5sudo pacman -S passpass relies on GPG (GNU Privacy Guard) for encrypting your passwords. You’ll need a GPG key pair to initialize your password store. If you don’t have one, you can generate a new key.
1gpg --full-gen-keyDuring the key generation process, you’ll be prompted for several choices:
(1) RSA and RSA (default).4096 bits is recommended for strong security.1y for one year) or choose 0 for no expiration.After generating or if you already have a GPG key, you need to identify its Key ID. This ID will be used to initialize pass.
1gpg --list-secret-keys --keyid-format LONGLook for a line similar to sec rsa4096/YOUR_KEY_ID 2023-01-01 [SC] and copy the YOUR_KEY_ID part (e.g., 0x12345678ABCDEF).
First, initialize your password store with your GPG key ID. This creates the .password-store directory in your home directory.
1pass init YOUR_GPG_KEY_IDYOUR_GPG_KEY_ID with the key ID you identified in the previous step (e.g., 0x12345678ABCDEF).To add a new password, use pass insert. You can organize your passwords in a folder-like structure.
1pass insert folder/titlepass insert social/facebook will create a file ~/.password-store/social/facebook.gpg.To retrieve and display a password, use pass show. You’ll be prompted for your GPG passphrase.
1pass show folder/titlepass show social/facebookTo list all stored passwords, simply run pass or pass ls.
1pass
2# or
3pass lsThis will show you the hierarchical structure of your password store.
One of the powerful features of pass is its seamless integration with Git. This allows you to synchronize your password store across multiple devices, maintain a history of changes, and easily recover previous versions of your passwords.
To initialize a Git repository within your password store:
1pass git initThis command creates a .git directory inside ~/.password-store/.
To synchronize your password store with a remote repository (e.g., a private GitHub repository):
1pass git remote add origin git@github.com:your_username/your_password_repo.git
2pass git push -u origin mastergit@github.com:your_username/your_password_repo.git with the actual SSH URL of your private repository.After making changes to your password store, you can push them to your remote repository:
1pass git add .
2pass git commit -m "Update passwords"
3pass git pushTo pull changes from the remote repository to another device:
1pass git pullSometimes you need to store more than just a single password, such as a username, URL, or notes. pass supports multiline entries, allowing you to store structured information within a single password file.
pass insert -mTo create a multiline entry, use the -m flag with pass insert:
1pass insert -m folder/titleThis will open your default text editor (e.g., vi, nano) where you can type your multiline content. The first line will be treated as the primary password, and subsequent lines can be custom fields.
A common and recommended format for multiline entries includes fields like username, password, and URL:
your_password_here
username: your_username
url: https://example.com
notes: additional notesWhen you pass show folder/title, only the first line (the password) will be displayed by default. To view the entire content, you can use pass show -c folder/title to copy the first line, or pass show folder/title | less to view the full file.
Your GPG private key is the master key to your password store. Losing it means losing access to all your encrypted passwords. Therefore, securely backing up your private key is critically important.
1gpg --list-secret-keys --keyid-format LONGNote down the `YOUR_KEY_ID` (e.g., `0x12345678ABCDEF`).
private-key-backup.asc in a very secure location (e.g., encrypted USB drive, secure cloud storage, hardware security module).1gpg --export-secret-keys --armor YOUR_KEY_ID > private-key-backup.asc1gpg --export --armor YOUR_KEY_ID > public-key-backup.ascWithout the private key that originally encrypted the passwords, the files are unreadable. Import your backup (.asc or .gpg file):
1gpg --import my_private_key.ascGPG often won’t allow pass to decrypt files unless the key is manually trusted on the new system.
gpg --list-secret-keys --keyid-format LONGgpg --edit-key <YOUR_KEY_ID>trust, select 5 (Ultimate), type y, then save.If you have a backup folder (e.g., from an external drive or cloud), move it to your home directory:
1mv /path/to/backup/.password-store ~/.password-storeIf you use Git for sync: Instead of moving a folder, clone your existing password repository:
1git clone user@server:/path/to/repo.git ~/.password-storeIf pass doesn’t immediately recognize the store or if you’ve moved to a new GPG key, re-initialize the store to ensure the .gpg-id file is correct:
1pass init <YOUR_GPG_ID>This doesn’t delete passwords; it just re-encrypts the internal ID file to match your current GPG key.
Try to show a password to see if the decryption works:
1pass show <FOLDER/SITE_NAME>If you get a “No secret key” or “Decryption failed” error on Arch/Hyprland:
gpg-agent is running.sudo pacman -S pinentry) so you can actually type your passphrase.~/.gnupg folder has the correct permissions:1chmod 700 ~/.gnupg
2find ~/.gnupg -type f -exec chmod 600 {} +
3find ~/.gnupg -type d -exec chmod 700 {} +If your pass store was previously a Git repo, you can re-enable the auto-syncing features by running:
1pass git pull