How to use the command 'pass otp' (with examples)

How to use the command 'pass otp' (with examples)

The ‘pass otp’ command is a pass extension that allows for the management of one-time-password (OTP) tokens. It can be used to insert, append, print, copy, and display OTP codes using pass files. Additionally, it supports the option to prompt for an OTP secret value specifying the issuer and account, and append it to an existing pass file.

Use case 1: Prompt for an otpauth URI token and create a new pass file

Code:

pass otp insert path/to/pass

Motivation: This use case is useful when setting up a new OTP token and wanting to store it in a pass file for easy access and management.

Explanation: The ‘pass otp insert’ command prompts for an otpauth URI token and creates a new pass file at the specified path.

Example output:

Enter otpauth URI token: otpauth://totp/Example:alice@google.com?secret=EXAMPLESECRET&issuer=Example
Inserted OTP token at path/to/pass

Use case 2: Prompt for an otpauth URI token and append to an existing pass file

Code:

pass otp append path/to/pass

Motivation: This use case is useful when wanting to add an additional OTP token to an existing pass file.

Explanation: The ‘pass otp append’ command prompts for an otpauth URI token and appends it to an existing pass file at the specified path.

Example output:

Enter otpauth URI token: otpauth://totp/Example:bob@google.com?secret=ANOTHERSECRET&issuer=Example
Appended OTP token to path/to/pass

Use case 3: Print a 2FA code using the OTP token in a pass file

Code:

pass otp path/to/pass

Motivation: This use case is useful when needing to quickly retrieve and display the current 2FA code for an OTP token stored in a pass file.

Explanation: The ‘pass otp’ command without any additional arguments prints the current 2FA code using the OTP token stored in the pass file at the specified path.

Example output:

123456

Use case 4: Copy and don’t print a 2FA code using the OTP token in a pass file

Code:

pass otp --clip path/to/pass

Motivation: This use case is useful when wanting to quickly copy the current 2FA code without printing it to the console.

Explanation: The ‘–clip’ option in the ‘pass otp’ command copies the current 2FA code to the clipboard using the OTP token stored in the pass file at the specified path.

Example output: (Clipboard content: 123456)

Use case 5: Display a QR code using the OTP token stored in a pass file

Code:

pass otp uri --qrcode path/to/pass

Motivation: This use case is useful when needing to visually scan the OTP token using a QR code scanner app or device.

Explanation: The ‘pass otp uri –qrcode’ command displays a QR code representation of the OTP token stored in the pass file at the specified path.

Example output: (QR code displayed on the screen)

Use case 6: Prompt for an OTP secret value specifying issuer and account and append to existing pass file

Code:

pass otp append --secret --issuer issuer_name --account account_name path/to/pass

Motivation: This use case is useful when wanting to manually enter an OTP secret value, along with specifying the issuer and account details, and append it to an existing pass file.

Explanation: The ‘pass otp append’ command with the additional options ‘–secret’, ‘–issuer’, and ‘–account’ prompts for an OTP secret value, issuer name, and account name, and appends it to an existing pass file at the specified path.

Example output:

Enter OTP secret value: MYSECRET
Enter issuer name: Example
Enter account name: alice@google.com
Appended OTP token to path/to/pass

Conclusion:

The ‘pass otp’ command is a versatile tool for managing OTP tokens using pass files. With its various options, it provides a seamless workflow for inserting, appending, printing, copying, and displaying OTP codes. Whether you need to set up a new OTP token, add to an existing pass file, retrieve a 2FA code, copy it to the clipboard, or display a QR code, ‘pass otp’ has you covered.

Related Posts

How to use the command 'puppet agent' (with examples)

How to use the command 'puppet agent' (with examples)

The puppet agent command is used to retrieve the client configuration from a Puppet server and apply it to the local host.

Read More
How to use the command hping3 (with examples)

How to use the command hping3 (with examples)

hping3 is an advanced ping utility that supports protocols such as TCP, UDP, and raw IP.

Read More
How to use the command a2dissite (with examples)

How to use the command a2dissite (with examples)

The a2dissite command is used to disable an Apache virtual host on Debian-based operating systems.

Read More