密碼管理應該很簡單。 這些命令行密碼管理器將我們的憑據、標題、Web URL、註釋和其他詳細信息存儲在加密文件中。 我們可以使用這些工具輕鬆管理我們的憑據。 我們甚至可以管理非常容易識別和排序的個人密碼文件。
這些工具提供用於編輯、添加、生成和檢索密碼的選項。 它包含一個非常簡短的 shell 腳本,能夠臨時將密碼放在剪貼板上並跟踪密碼更改。
在本文中,我將解釋兩個命令行密碼管理器工具。
1. 密碼管理器
它是簡單便攜的密碼管理器工具。 它安全地存儲密碼並通過命令行檢索它們。 在默認模式下,passmgr 允許選擇存儲的密碼短語,然後在有限的時間內將其複製到剪貼板,以便粘貼到密碼短語字段中。 在此之後,剪貼板將被擦除。
所有憑據都存儲在 AES256-GCM 加密的單個文件中,默認情況下該文件位於用戶主目錄中。 此文件的加密密鑰是從使用 scrypt 的主密碼派生而來的。
先決條件
- 安裝 Go
- 要安裝的 Xclip 或 Xsel 命令
在安裝 Passmgr 之前,我們需要滿足這些先決條件。
安裝 Go
根據我們的服務器架構,我們可以下載所需的包並解壓安裝。
#yum update
# wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
# tar -xzvf go1.6.2.linux-amd64.tar.gz -C /usr/local/
我已經下載了 64 位架構的包。 您可以像以前一樣在服務器範圍內創建工作文件夾設置環境變量。
# cd /root
# mkdir go
# cat /etc/profile.d/goenv.sh
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
# source /etc/profile.d/goenv.sh
# go version
go version go1.6.2 linux/amd64
安裝 Xclip 或 Xsel
要在 CentOS 7 服務器中啟用這些命令,我們需要先安裝這些依賴包,然後再進行包安裝。 請按照以下步驟啟用此命令。
# yum install libX11.x86_64
# yum install libX11-devel.x86_64
# yum install libXmu.x86_64
# yum install libXmu-devel.x86_64
# wget ftp://mirror.switch.ch/pool/4/mirror/epel/7/x86_64/x/xclip-0.12-5.el7.x86_64.rpm
# wget https://dl.fedoraproject.org/pub/epel/7/x86_64/x/xsel-1.2.0-15.el7.x86_64.rpm
# rpm -Uvh xsel-1.2.0-15.el7.x86_64.rpm
warning: xsel-1.2.0-15.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:xsel-1.2.0-15.el7 ################################# [100%]
# rpm -Uvh xclip-0.12-5.el7.x86_64.rpm
warning: xclip-0.12-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:xclip-0.12-5.el7 ################################# [100%]
安裝 Passmgr
完成上述安裝後,我們可以一步啟用此 Passmgr 工具,如下所示:
# go get github.com/urld/passmgr/cmd/passmgr
現在我們可以運行 "passmgr"
為我們的密碼管理器工具設置主密碼並使我們的工具進入我們的主要條目。
# passmgr
[passmgr] new master passphrase for /root/.passmgr_store:
[passmgr] retype master passphrase for /root/.passmgr_store:
-- store is empty --
Choose a command [(S)elect/(f)ilter/(a)dd/(d)elete/(q)uit] a
Enter the values for the new entry
User: Saheetha
URL: linoxide.com
Passphrase:
n) User URL
1) Saheetha linoxide.com
密碼管理器用途
該工具提供了各種管理密碼的選項。 我們可以使用這些選項添加、刪除、搜索特定字符串。 我們可以運行 help 命令來列出使用此工具的所有可能選項。
# passmgr --help
Usage of passmgr:
-add
store new credentials
-appTTL int
time in seconds after which the application quits if there is no user interaction (default 120)
-clipboardTTL int
time in seconds after which the clipboard is reset (default 15)
-del
delete stored credentials
-file string
specify the passmgr store (default "/root/.passmgr_store")
例子:
您可以使用選項 –add 向我們的密碼管理器工具添加新條目,如下所示:
# passmgr -add
[passmgr] master passphrase for /root/.passmgr_store: docker
n) User URL
1) Saheetha linoxide.com
Enter the values for the new entry
User: [email protected]
URL: work.example.com
Passphrase:
n) User URL
1) Saheetha linoxide.com
2) [email protected] work.example.com
我們可以使用選項 –file 將憑據存儲/讀取到文件中。 默認情況下,所有密碼都將存儲在“/root/.passmgr_store”文件中。 我們可以使用以下命令讀取特定條目的密碼文件:
# passmgr -file /root/.passmgr_store
[passmgr] master passphrase for /root/.passmgr_store:
n) User URL
1) Saheetha linoxide.com
2) [email protected] work.example.com
3) testuser website.com
Choose a command [(S)elect/(f)ilter/(a)dd/(d)elete/(q)uit] 1
Choose a command [(S)elect/(f)ilter/(a)dd/(d)elete/(q)uit] S
Select: 1
Passphrase copied to clipboard!
Clipboard will be erased in 15 seconds.
我們可以使用過濾器選項將我們的搜索限制為特定的字符串,如下所示:
# passmgr
[passmgr] master passphrase for /root/.passmgr_store:
n) User URL
1) Saheetha linoxide.com
2) [email protected] work.example.com
3) testuser website.com
4) test test.com
Choose a command [(S)elect/(f)ilter/(a)dd/(d)elete/(q)uit] f
Filter: test
n) User URL
3) testuser website.com
4) test test.com
過濾器可以通過將其留空來重置。
要從密碼管理器工具中刪除條目,我們可以使用選項 d 或刪除。 請參閱 example 以下:
# passmgr
[passmgr] master passphrase for /root/.passmgr_store:
n) User URL
1) Saheetha linoxide.com
2) [email protected] work.example.com
3) testuser website.com
4) test test.com
Choose a command [(S)elect/(f)ilter/(a)dd/(d)elete/(q)uit] d
Delete: 3
Delete all secrets for 'testuser | website.com? [Y/n] y
n) User URL
1) Saheetha linoxide.com
2) [email protected] work.example.com
3) test test.com
Choose a command [(S)elect/(f)ilter/(a)dd/(d)elete/(q)uit] q
在這 example,我已經刪除了 "testuser"
從我的密碼管理器進入。
2.泰坦
Titan 是另一種命令行密碼管理器工具,可用於任何 Unix 類型的操作系統。 它使用 OpenSSL 庫來執行加密。 AES 加密與 256 位密鑰一起使用。 在 Titan 中,密碼數據庫還通過使用密鑰散列消息身份驗證代碼 (HMAC) 來防止篡改。 在加密期間使用唯一的、密碼學上隨機的初始化向量。 每次加密密碼數據庫時都會生成新的初始化向量。
Titan 使用 SQLite 來存儲密碼。 數據庫架構簡單易行。
我已經按照這些步驟為我們的 CentOS7 服務器安裝 Titan。
# yum install sqlite-devel.x86_64 sqlite-tcl.x86_64
# yum install openssl-devel
# git clone https://github.com/nrosvall/titan.git
# cd titan/
# make
# make install
泰坦用途
Titan 還提供了一些通過命令行管理密碼的選項。 讓我們來看看下面的幾個:
首先,我們需要創建一個數據庫來存儲我們的密碼。 我們可以通過運行這個命令來創建我們的新數據庫。
# titan --init /home/passwords/passwd.db
您可以在創建時提供密碼來保護此數據庫。 現在您可以使用 --add or just -a
選項如下:
# titan --add
Title: Work
Username: sshameer
Url: linoxide.com
Notes: Admin notes
Password (empty to generate new):
我們的數據庫應該被解密以添加條目。 為了解密它,您可以使用選項 Titan –decrypt [database path]. 這裡我們可以使用:
# titan --decrypt /home/passwords/passwd.db
要查看添加的條目,您可以使用該選項 "--list-all".
# titan --list-all
=====================================================================
ID: 1
Title: Work
User: sshameer
Url: linoxide.com
Password: **********
Notes: Admin notes
Modified: 2017-07-08 15:11:56
=====================================================================
添加所有可能的條目後,您應該加密我們的密碼數據庫以確保安全。 我們可以運行這個命令來加密它。
#titan --encrypt /home/passwords/passwd.db
請參見 man titan
或者 titan --help
想要查詢更多的信息。
我最近發現了另一個命令行密碼管理器“通孔” 使用 KeePass 數據庫。
包起來
當您通過 SSH 遠程登錄時,命令行密碼管理器既簡單又出色。 將所有現有密碼輸入密碼管理器是一個很好的第一步。 密碼管理器使良好的安全性盡可能簡單。 您需要做的就是記住一個主密碼(讓它成為一個好密碼!),密碼管理器會處理其餘的,根據需要為每個帳戶生成和保存一個唯一的密碼。 除了加密這些登錄憑據外,它還安全地存儲它們。 感謝您閱讀本文,如果您發現更多工具,請隨時在此處分享。