pass

提供: ArchWiki
2020年8月12日 (水) 09:35時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (英語版より一部転載)
ナビゲーションに移動 検索に移動

pass はコマンドライン用のシンプルなパスワードマネージャです。パスワードは単純なディレクトリツリー構造の gpg で暗号化されたファイルの中に保存されます。pass はシェルスクリプトであり gnupg, tree, git などの既存のツールを利用します。

インストール

pass パッケージをインストールしてください。

ヒント: 任意で qtpass パッケージをインストールすることで Qt 製の GUI を使うことができます。

基本的な使い方

ノート: pass を使用するには GnuPG#基本的な鍵の管理 に書かれているようにして gnupg をセットアップする必要があります。

パスワードストアを初期化:

$ pass init <gpg-id or email>

パスワードを挿入、わかりやすい階層名を指定する:

$ pass insert archlinux.org/wiki/username

パスワードストアを確認:

$ pass
Password Store
└── archlinux.org
    └── wiki
        └── username

新しいランダムなパスワードを生成、<n> は生成するパスワードの長さ (数字) に置き換えてください:

$ pass generate archlinux.org/wiki/username <n>

パスワードを再取得、gpg のパスワードの入力を求められます:

$ pass archlinux.org/wiki/username

Xorg を使っていて xclip をインストールしている場合、以下のコマンドで取得したパスワードを一時的にクリップボードにコピーできます:

$ pass -c archlinux.org/wiki/username
ノート: 中クリックによる貼り付けを使いたい場合はシェルの設定ファイルに次のように追加してください: export PASSWORD_STORE_X_SELECTION=primary

pass には検索やコピーを楽にする dmenu ラッパーが付属しています。使用するには、dmenu をインストールして次のコマンドを実行:

$ passmenu

エントリを選択することクリップボードにパスワードがコピーされます。大文字・小文字の区別などカスタマイズオプションについては man dmenu を見てください。キーバインドを設定することでアプリケーションから簡単にパスワードが使えるようにすることもできます。

pass への移行

pass のプロジェクトページ に他のプログラムからパスワードをインポートするためのスクリプトが複数記載されています。

拡張

バージョン 1.7 から、pass はコミュニティが開発した拡張をサポートしています。以下の拡張をインストールすることで pass の機能を強化することができます。

tomb の中で暗号化されたパスワードストアのツリーを管理します。

ワンタイムパスワード (OTP) トークンのサポート。

他のパスワードマネージャからのインポートツール。

簡単にパスワードをアップデート。

高度な使い方

環境変数を使うことで pass が使用するパスワードストアのディレクトリや git ディレクトリを変更できます:

PASSWORD_STORE_DIR=/path/to/store
PASSWORD_STORE_GIT=/path/to/store

複数の pass リポジトリを使用する方法ついて詳しくは こちらのリンク を参照してください。

複数の pass コンテキスト

エイリアスを使うことで様々な pass コンテキストを設定できます。異なるチームで作業を行う場合などに有用です。

~/.bashrc に以下のエイリアスを追加してください:

alias passred="PASSWORD_STORE_DIR=~/.pass/red PASSWORD_STORE_GIT=~/.pass/red pass"
alias passblue="PASSWORD_STORE_DIR=~/.pass/blue PASSWORD_STORE_GIT=~/.pass/blue pass"

bash-completion をインストールして ~/.bash_completion に以下を追加してください:

source /usr/share/bash-completion/completions/pass
_passred(){
    PASSWORD_STORE_DIR=~/.pass/red/ _pass
}
complete -o filenames -o nospace -F _passred passred
_passblue(){
    PASSWORD_STORE_DIR=~/.pass/blue/ _pass
}
complete -o filenames -o nospace -F _passblue passblue

~/.pass/red~/.pass/blue を初期化したら passredpassblue エイリアスで2つの pass コンテキストを交互に使うことができます。コンテキストは好きなだけ追加できます。

GUI

qtpass パッケージをインストールしてください。

Git の統合

git の認証ヘルパーとして pass を使うことができます。pass-git-helperAUR または pass-git-helper-gitAUR パッケージをインストールしてください。

使用方法

詳しい使い方は github の README ファイル に書かれています。

git の設定

以下のコマンドを実行して git の認証ヘルパーとして pass-git-helper をインストール:

$ git config --global credential.helper /usr/bin/pass-git-helper

マッピングファイル

~/.config/pass-git-helper/git-pass-mapping.ini ファイルを作成してください。git のリモートホストを pass データベースにマッピングできます。フォーマットは以下の通りです:

[github.com]
target=dev/github

[*.fooo-bar.*]
target=dev/fooo-bar

上記の通りホスト部にはワイルドカードを使うことができます。

パスワードストアレイアウト

pass と同じように、パスワードストアエントリの最初の行にパスワードを指定します。二行目はユーザー名として解釈されます。

機能させるには pass insert --multiline を使って複数行のパスワードストアエントリを作成する必要があります。


Central Git server for pass in combination with GnuPG (SSH example)

You are able to setup a password management system by setting up a central Git server for pass. This allows you to synchronize your central password repository through multiple client environments.

Install a bare Git repository for pass on the server

On the server run git init --bare ~/.password-store to create a bare repository you can push to.

Import authorized public SSH keys

See SSH keys#Copying the public key to the remote server

On the client

This section assumes you have configured GnuPG and have a key pair to encrypt passwords. On your local client ensure you have a local password store on the client, then enable management of local changes through Git, add your remote Git repository, and push your local pass history.

# Create local password store
pass init <gpg key id>
# Enable management of local changes through Git
pass git init
# Add the the remote git repository as 'origin'
pass git remote add origin user@server:~/.password-store
# Push your local pass history
pass git push -u --all

Now you can use the standard Git commands, prefixed by pass. For example: pass git push, or pass git pull. pass will automatically create commits when you use it to modify your password store.

Troubleshooting

Encryption failed: Unusable public key

The following error can occur when attempting to insert a new entry:

$ pass insert archlinux.org/wiki/username
Enter password for archlinux.org/wiki/username:
Retype password for archlinux.org/wiki/username:
gpg: XXXXXXXXX: There is no assurance this key belongs to the named user
gpg: [stdin]: encryption failed: Unusable public key
Password encryption aborted.

This occurs if the trust level of the GnuPG key is set to anything other than "ultimate." Edit the key used for pass to set its trust level to "ultimate."

参照