Secret Pass

Secret Pass

Article from Issue 215/2018
Author(s):

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

PASSWORD_STORE_DIR

Folder for password files

PASSWORD_STORE_GENERATED_LENGTH

Standard length of passwords generated

PASSWORD_STORE_ENABLE_EXTENSIONS

Enables extensions

PASSWORD_STORE_EXTENSIONS_DIR

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.

Figure 1: Once you have accumulated various access datasets, you can easily organize them in a folder structure that Pass displays as a tree when called without parameters.

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

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News