How to use command line to manage passwords in Linux
In today's popular password-based authentication on the internet, you may need or have used a password management tool to track and manage all the passwords you are using. There are a variety of online or offline services or software tools used to accomplish such things, and these tools, due to complexity, user interface or target environment (such as enterprise or end user) and are different. For example, some are graphical-based password managers developed for end users, such as KeePass (X ).
20 most popular Linux commands, do you agree?
Linux Command cd
Cat for Linux commands
Linux Command alias/unalias
Linux Command Parsing: su root and su-root
Interactive input of Linux commands read
For users who do not want to rely on graphical password management, the author will describe how to use pass to manage passwords in the command line. This is a simple tool for managing passwords in the command line.
The password tool is actually a front end of shell script writing. It calls several other tools (such as gpg, pwgen, git, and xsel) to use OpenGPG to manage user password information. Each password is encrypted using the gpg tool and stored in the Local Password repository. Password information can be used through a terminal or a self-clearing clipboard tool.
The password tool is flexible and easy to use. You can store each password information in an OpenGPG-protected plain text file and group different password files into multiple categories. It supports bash auto-completion, so you can easily use the TAB key to complete the command or a long password name.
Install pass on Linux
Install pass On Debian, Ubuntu, or Linux Mint:
- $ Sudo apt-get install pass
- $ Echo "source/etc/bash_completion.d/password-store" >> ~ /. Bashrc
Install pass on Fedora:
- $ Sudo yum install pass
- $ Echo "source/etc/bash_completion.d/password-store" >> ~ /. Bashrc
To install pass on CentOS, first enable the EPEL repository (SEE) and then execute the following command:
- $ Sudo yum install pass
- $ Echo "source/etc/bash_completion.d/password-store" >> ~ /. Bashrc
Install pass on Archlinux:
- $ Sudo pac-S pass
- $ Echo "source/etc/bash_completion.d/password-store" >> ~ /. Bashrc
Initialize the Local Password Repository
Before using the password tool, you need to perform an initialization step, which includes creating a GPG key pair (if you do not have one) and a local password repository.
First, create a GPG key pair (Public Key/private key) by following these steps ). Skip this step if you have created your own GPG key pair.
- $ Gpg -- gen-key
After performing this step, you will be asked the following questions. If you are not sure, you can accept the default answer. As part of key generation, you will create an encrypted password for your key. This password is actually the master password when you access any password information stored in the Local Password repository. After a key pair is created, the created key pair is stored in ~ /. Gnupg directory.
Next, run the following command to initialize the Local Password repository. Enter the email address associated with the key pair.
- $ Pass init <gpg-id>
This command will be in ~ /. Password-store directory to create a password repository.
Use the pass management password on the terminal to insert new password information
To insert new password information into the Local Password repository, follow the command format below:
- $ Pass insert <password-name>
Is the proprietary name you define and can be classified (such as "finance/tdbank", "online/gmail.com "). In this case, the password information can be stored in ~ /. Password-store directory.
If you want to insert password information in multiple lines, use the "-m" option like the following command. Enter the password information in any format you like and press Ctrl + D.
- $ Pass insert <password-name>-m
For more details, please continue to read the highlights on the next page: