Description
pass otp extends the pass utility with an otp command for managing OTP tokens:
adding secrets, generating codes and displaying key URIs in the standard
Key Uri Format. It supports both time-based (TOTP) and counter-based (HOTP)
tokens.
The token is stored as an otpauth:// line inside a regular password file, so it can
live in its own entry or next to the password it protects. The HOTP counter is updated
(and committed when the store is a git repository) each time a code is generated.
Codes are generated with oathtool. pass otp works with both pass (GPG) and
passage (age).
Pass otp is compatible with browser extensions: passff fills OTP fields with codes
from pass otp, and browserpass generates TOTP codes from the same otpauth:// line.
Usage
pass otp 1.2.0 - Manage one-time-password (OTP) tokens.
Usage:
pass otp [code] [--clip,-c] pass-name
Generate an OTP code and optionally put it on the clipboard.
If put on the clipboard, it will be cleared in 45 seconds.
pass otp insert [--force,-f] [--echo,-e]
[[--secret, -s] [--issuer,-i issuer] [--account,-a account] [--path,-p path-name]]
[pass-name]
Prompt for and insert a new OTP key.
If 'secret' is specified, prompt for the OTP secret, assuming SHA1
algorithm, 30-second period, and 6 OTP digits; one of 'issuer' or
'account' is also required. Otherwise, prompt for a key URI; if
'pass-name' is not supplied, use the URI label.
Optionally, echo the input. Prompt before overwriting existing URI
unless forced. This command accepts input from stdin.
pass otp append [--force,-f] [--echo,-e]
[[--secret, -s] [--issuer,-i issuer] [--account,-a account]]
pass-name
Appends an OTP key URI to an existing password file.
If 'secret' is specified, prompt for the OTP secret, assuming SHA1
algorithm, 30-second period, and 6 OTP digits; one of 'issuer' or
'account' is also required. Otherwise, prompt for a key URI.
Optionally, echo the input. Prompt before overwriting an existing URI
unless forced. This command accepts input from stdin.
pass otp uri [--clip,-c] [--qrcode,-q] pass-name
Display the key URI stored in pass-name. Optionally, put it on the
clipboard, or display a QR code.
pass otp validate uri
Test if the given URI is a valid OTP key URI.
More information may be found in the pass-otp(1) man page.
Examples
Prompt for an OTP token, hiding input
$ pass otp insert totp-secret
Enter otpauth:// URI for totp-secret:
Retype otpauth:// URI for totp-secret:
Prompt for an OTP token, echoing input
$ pass otp insert -e totp-secret
Enter otpauth:// URI for totp-secret: otpauth://totp/totp-secret?secret=AAAAAAAAAAAAAAAA&issuer=totp-secret
Pipe an otpauth:// URI into a passfile
$ pass otp insert totp-secret < totp-secret.txt
Use zbar to decode a QR image or webcam shot into a passfile
$ zbarimg -q --raw qrcode.png | pass otp insert totp-secret
To use your webcam:
$ zbarcam -q --raw | pass otp insert totp-secret
The same, but appending to an existing passfile:
$ zbarimg -q --raw google-qrcode.png | pass otp append google/example@gmail.com
You can also select “Copy Image” in your favorite browser or take a screenshot of the QR code and run:
With Wayland:
$ wl-paste | zbarimg -q --raw - | pass otp append google/example@gmail.comWith X11:
$ xclip -selection clipboard -o -target image/png | zbarimg -q --raw - | pass otp append google/example@gmail.comOn MacOS, use
pngpaste -
Generate a 2FA code using this token
$ pass otp totp-secret
698816
Display a QR code for an OTP token
$ pass otp uri -q totp-secret
█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ ██▄▄ ▀█ ▀ █▀█ ▄▄▄▄▄ ████
████ █ █ █▀▄ █▀▀▄▀▀██ █ █ █ ████
████ █▄▄▄█ █▄▀ █▄▄▄ █▀▀▄ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄▀▄█ ▀ █▄█ ▀▄█▄▄▄▄▄▄▄████
████▄▄▀██▄▄ ▀▄ █▄█▀ ▀▄▀▀▄▀█▀ ▄▀██████
████ ▀▄▀ ▄▀ ▄▀ ▄▄ ▄ ███ ██ █ ███████
████▀▀ ▄▄█▄▄▄▄ █ █ ▀███▀▄▀ ▀▀█ ████
████▀▄▀ ▀ ▄█▀▄██ ▀▀▄██▀█▀▄▀▀ ▀█▀████
████▀ █▀ ▄▄██ █▀▄▄▄ ▄▀ ▄▀ ▀ ▄▀▀████
████ ▄ ▀█ ▄█▄ ▀ ▄██▄▀██▄ ▀▀▀█ ▄▀ ████
████▄█▄▄▄█▄▄ █▄▄ ▀█ █▄█▀ ▄▄▄ █▄█▄████
████ ▄▄▄▄▄ █ ▄▀▀▀▀▄ █▄▄ █▄█ ███▀████
████ █ █ ██▀▄ █▄█ ▀█▀ ▄▄▄█▀▄ ████
████ █▄▄▄█ █▀▄ █ █ ██▄▄▀ ▀▄█ ▄▀████
████▄▄▄▄▄▄▄█▄█▄▄███▄█▄█▄█▄█▄██▄██████
█████████████████████████████████████
█████████████████████████████████████
Migrating from pass-otp 0.1
pass-otp has switched to storing OTP tokens in the
standard
Key Uri Format.
You’ll need to edit any saved tokens and change them to this format. For
example:
$ pass edit totp-secret
Old format:
otp_secret: AAAAAAAAAAAAAAAA
otp_type: totp
otp_algorithm: sha1
otp_period: 30
otp_digits: 6
New format:
otpauth://totp/totp-secret?secret=AAAAAAAAAAAAAAAA&issuer=totp-secret
Note that the following default values do not need to be specified in the URI:
| parameter | default |
|---|---|
| algorithm | sha1 |
| period | 30 |
| digits | 6 |
Migrating from Google Authenticator
Warning: This method is provided as a means to transport your TOTP tokens to other devices, disconnected from your single factor authentication part. If you add those secrets into the same basket of eggs, you will be defeating the whole purpose of the multi factor authentication mantra. Please think it through before running this migration.
If you read the warning paragraph above, keep calm and move on with the migration.
Installation
Requirements
pass 1.7.0or greater.oathtoolorPass::OTPto generate codes.qrencodeto display QR codes.
ArchLinux
pacman -S pass-otp
Debian/Ubuntu
apt install pass-otp
Fedora
dnf install pass-otp
Gentoo
emerge app-admin/pass-otp
NixOS
pass.withExtensions (exts: [ exts.pass-otp ])
openSUSE
zypper install pass-otp
OSX
brew install pass-otp # or: sudo port install pass-otp
From git
git clone https://github.com/pass-extension/pass-otp/
cd pass-otp
sudo make install # For OSX: make install PREFIX=$(brew --prefix)
To use with passage, install into one of passage’s extension directories:
sudo make install SYSTEM_EXTENSION_DIR=/usr/lib/passage/extensions
Contribution
Feedback, contributors, pull requests are all very welcome.