Secret Pass
Secret Pass
Pass is a simple shell script that helps you manage and synchronize passwords using Git.
If you are like many Linux users today, you have dozens of online accounts for different services and websites. If you care about security, you are really not supposed to give those accounts the same password; nor is it considered safe to write all your passwords down on paper and store it in your desk drawer. Password managers evolved as a means for letting users store their passwords safely. Password managers differ in form and functionality, but the basic idea is that the password manager stores your passwords in a safe, encrypted format, and you provide one password to gain access to the password store. Instead of having to memorize all your passwords, you just have to memorize one.
Pass [1] is a lean password manager that relies on some classic Linux tools to help you generate and manage your passwords.
What Is Pass?
Pass is basically just a shell script that bundles various tasks involved in managing passwords into functions that are easy to use. The Pass script integrates a number of other tools that make it possible to back up data using strong cryptography, to copy passwords directly to the clipboard, or to manage the entire database using a version control system.
Pass uses GnuPG to encrypt files, Git to manage the files, and xclip
to copy them to the clipboard. When installing Pass, most package managers automatically update the existing GnuPG files. In addition to xclip
, the program usually requires a tool for displaying directory hierarchies (tree
) (Listing 1).
Listing 1
The tree Tool
$ pacman -Si pass Repositorium : community Name : pass Version : 1.7.1-1 Description : Stores, retrieves, generates, and synchronizes passwords securely Architecture : any URL : https://www.passwordstore.org/ Licences : GPL2 Groups : None Provides : passmenu Depends on : xclip bash gnupg tree Optional dependencies : git: for Git support dmenu: for passmenu qrencode: for QR code support Conflicts with : passmenu Replaces : passmenu Download size : 18.33 KB Installation size : 45.00 KB Packer : Lukas Fleischer <lfleischer@archlinux.org> Created on : Fr 14 Apr 2017 10:31:38 CEST Verified by : MD5 sum SHA-256 sum Signature
GnuPG lets you create a key suitable for signing or encrypting data, and Pass takes advantage of this function. It is still a somewhat complicated matter to create a key correctly and then keep it safe. However, various pages on the web can help you get started with the subject [2].
Initializing
If you call the tool with the init
parameter, it also requires the ID of the GnuPG key that you will be using to encrypt the files. Use the -p <directory>
option to specify that the key only applies to a subtree of the password collection. You can separate business passwords from private passwords in this way.
All the files you manage with Pass are located below .password-store/
in your home directory. If you want to use a different directory, set the environment variable PASSWORD_STORE_DIR
accordingly (see Table 1).
Table 1
Key Variables
|
Folder for password files |
|
Standard length of passwords generated |
|
Enables extensions |
|
Folder for extensions |
If you already use a password management program, the Pass website is well worth a visit: You will find a whole range of tools and scripts that help you export data from other programs, such as Revelation or KeePass. In our lab, exporting from Revelation worked without any problems. In each of the files, the additional entries were located in one line.
Pass only evaluates the first line of the file in which it writes the password for the respective access case. Further information is only used to note down usernames or URLs and other data.
If you are starting from scratch, call Pass with the generate
parameter, a name for the access case, and a number for the desired password length:
$ pass generate test/access 23
In the example, the password would be 23 characters long, and the corresponding file would end up in the access
file below the test/
password directory subfolder. If you call Pass for this access case, the software prompts you for the password to access the GnuPG key. If you enter this correctly, Pass opens the file and outputs the content to your standard output.
The -c
option copies the content directly to the clipboard, from where you can paste it again with Ctrl+V. The XSel program is used for this step. If you enter a number as the option parameter, the program tries to read the corresponding line and copy it to the clipboard. In this way, a username could also be read from the corresponding file.
Over time, a volume of access data will tend to accumulate in this way. To organize the data, simply create subfolders in the root folder (.password-store
) and move the files with the data accordingly. If you call Pass without parameters in the terminal, it shows exactly this tree structure (Figure 1). The names of the files and directories correspond to the entries for the nodes. However, the tool does not include the .gpg
extension, thus making it easier to read.
Properly Managed
If you use more than one computer, you might not always store the access data on the same computer. It is also easy to imagine circumstances in which a new account becomes necessary while you are traveling. The data you need is then on your laptop's hard disk, but you might want to continue working on your home PC later on.
A whole series of approaches are now available to help you keep a synchronous set of data across all systems; after all, Pass works with simple files. Tools like rsync
work this way: In a single step, you copy either from the mobile computer to the stationary PC or vice versa. Synchronizing in the opposite direction always requires a second step, which could be done in one go with Unison [3], but it can be done even more elegantly.
At this point, the Git [4] version control system (VCS) enters the game. Git's real purpose is to manage source code and, often additionally, the documentation and other files that come with programs. However, the software is designed in such a way that it does not really matter what kind of data you manage with it.
Pass allows you to use Git to set up your own commands. You can synchronize files and, if desired, even store the files on a central host.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.