Simplify Password Management with the 'pass' Command-Line Password Manager
Tags: linux, beginners, security
Published: 2023-06-30 01:47:15

## Introduction
In this blog post, we will explore the **Pass - command-line password manager**, which provides a secure and convenient way to manage your passwords. We will start with the initial setup, including generating a GPG key, and then proceed to cover storing, retrieving, and removing passwords using 'pass'. We will also discuss additional tips and best practices for using 'pass' effectively.

### Initial setup
#### :key: Generating a GPG Key 

The first step to setting up the 'pass' password manager is generating a **GPG (GNU Privacy Guard) key**. GPG provides encryption and decryption functionality, securing your passwords in the 'pass' password store. To generate a GPG key, use the following command:

```sh
$ gpg --gen-key
```
You will be prompted to enter your name and email address. Additionally, you will be asked to set a **`passphrase`**.
 
<u>**Note**</u>
This passphrase is crucial as it acts as the master password for all your passwords, so make sure to choose a strong and memorable passphrase.

Copy your GPG Key `6G5E33C8EDF352343243256F23FW23A06C20` from the output
```
pub ...
6G5E33C8EDF352343243256F23FW23A06C20
```


#### :lock: Installing pass

Next, you need to install the 'pass' password manager on your system. The installation process may vary depending on your distribution. Here are a few examples:

```sh
sudo dnf install pass # Fedora
sudo apt install pass # Debian/Ubuntu/PopOS!
...
```

Now your :lock: + :key: are ready, so create a 'password-store'
```sh
$ pass init <GPG KEY>
# pass init 6G5E33C8EDF352343243256F23FW23A06C20
```
a directory `.password-store` will be created in your HOME, this dir stores all your passwords (that simple it is!)

### Storing passwords
* Inserting your own password

You want to store your Github password but you have two personal and work accounts, do this
```sh
$ pass insert github/personal
Enter password for github/personal: ...
$ pass insert github/work
Enter password for github/work: ...
```
Checkout `.password-store`, it'll look like this
```
📂  .password-store
└── 📂 github
   ├── 🔑 personal.gpg
   └── 🔑 work.gpg
```

* Generating random password
```sh
$ pass generate github/personal
```
A random password will be generated and stored under the specified label.

### Retrieving passwords
To retrieve your stored passwords, you will need to provide the passphrase you set during the GPG key generation. Here are two ways to retrieve passwords:

* Show password in terminal
```sh
$ pass show github/personal
YOUR_PASSWORD
```
* Copy password in clipboard for 45 seconds
```sh
$ pass show -c github/personal
Copied github/personal to clipboard. Will clear in 45 seconds.
```

### Removing passwords
```sh
$ pass rm github/personal
Are you sure you would like to delete github/personal? [y/N]
removed '/home/USER/.password-store/github/personal.gpg'
```

## Conclusion
Checkout offical website for pass  https://www.passwordstore.org/ to learn more.

There are many UI interfaces available for pass, if you use GNOME I have one for you...
{% embed https://github.com/Anant-mishra1729/Pass-zenity %}

Remember to refer to the 'pass' documentation or run man pass in the terminal for more detailed information on additional features and advanced usage of the 'pass' command-line password manager.