How to Manage Passwords Using the Command Line on Linux

         With password-based authentication so prevalent, you may already use a password management tool. There are various options varying in complexity, UI, and target environment. For example, there are GUI-based password managers likeKeePass(X)

For those who prefer CLI over GUI, I will explain how to use passto manage passwords,a simple command-line password management tool.

This tool is a shell script frontend that calls tools like gpg, pwgen, git, and xsel to manage passwords with OpenPGP. Each password is encrypted with gpg and stored in a local store. Passwords can be accessed via terminal or auto-clearing clipboard.

It is flexible and easy to use. Store passwords in OpenPGP-protected text files organized into categories. It supports bash autocompletion with TAB.

Install pass on Linux

Install pass on Debian, Ubuntu, or Linux Mint:


  1. $ sudo aptget install pass
  2. $ echo “source /etc/bash_completion.d/password-store” >> ~/.bashrc

Install pass on Fedora:


  1. $ sudo yum install pass
  2. $ echo “source /etc/bash_completion.d/password-store” >> ~/.bashrc

Install pass on CentOS: firstenable the EPEL repository, then run:


  1. $ sudo yum install pass
  2. $ echo “source /etc/bash_completion.d/password-store” >> ~/.bashrc

Install pass on Arch Linux:


  1. $ sudo pac S pass
  2. $ echo “source /etc/bash_completion.d/password-store” >> ~/.bashrc

Initialize Local Password Store

Before using pass, initialize it by creating a GPG key pair and a local password store.

First, create a GPG key pair (public/private). Skip if you have one.


  1. $ gpg genkey

You will be prompted; accept defaults if unsure. Create a passphrase – your master password stored in ~/.gnupg directory.

Next, initialize the local password store with the email associated with your GPG key:


  1. $ pass init <gpgid>

This creates a password store in ~/.password-store.

Manage Passwords with pass in Terminal

Insert New Password

To insert a new password into the store:


  1. $ pass insert <passwordname>

is a unique, optionally hierarchical name. Passwords are stored in corresponding subdirectories.

Use the -m option for multi-line input. Enter in any format and press Ctrl+D to finish.


  1. $ pass insert <passwordname> m

List All Password Names

To list all stored password names, simply type “pass”:


  1. $ pass

Retrieve Password from Store

To access a specific password:


  1. $ pass <passwordname>

Example:


  1. $ pass email/gmail.com

will prompt for your passphrase to unlock the key.

To copy password to clipboard instead of displaying it:


  1. $ pass c email/gmail.com

The clipboard is automatically cleared after 45 seconds.

Generate and Store New Password

You can also generate a random password with pass, specifying length and whether to include symbols.

Generate a 10-character password without symbols:


  1. $ pass generate email/new_service.com 10 n

Remove Password

Removing a password is easy:


  1. $ pass rm email/gmail.com

In summary, pass is flexible, portable, and easy to use. I highly recommend it for secure CLI-based password management.


via: http://xmodulo.com/2014/05/manage-passwords-command-line-linux.html

Leave a Comment

Your email address will not be published.