Linux command
2fa 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Add a new TOTP secret
2fa -add [account_name]
Generate a TOTP code
2fa [account_name]
List all configured accounts
2fa -list
Add a secret with a specific issuer
2fa -add -issuer=[issuer_name] [account_name]
Generate codes for all accounts
2fa
说明
2fa is a command-line two-factor authentication tool that generates time-based one-time passwords (TOTP) compatible with services like Google Authenticator. It stores secrets securely in a local file and produces 6-digit codes that refresh every 30 seconds. The tool reads TOTP secrets in base32 format (the same format shown when setting up 2FA on websites). When run without arguments, it displays codes for all configured accounts. Specify an account name to get only that code. Secrets are stored in ~/.2fa by default. The file should be protected with appropriate permissions as it contains sensitive authentication material.
参数
- -add
- Add a new account. Prompts for the base32-encoded TOTP secret.
- -list
- List all configured account names.
- -issuer _name_
- Specify the issuer name when adding an account (for organization).
- -clip
- Copy the generated code to clipboard instead of printing.
FAQ
What is the 2fa command used for?
2fa is a command-line two-factor authentication tool that generates time-based one-time passwords (TOTP) compatible with services like Google Authenticator. It stores secrets securely in a local file and produces 6-digit codes that refresh every 30 seconds. The tool reads TOTP secrets in base32 format (the same format shown when setting up 2FA on websites). When run without arguments, it displays codes for all configured accounts. Specify an account name to get only that code. Secrets are stored in ~/.2fa by default. The file should be protected with appropriate permissions as it contains sensitive authentication material.
How do I run a basic 2fa example?
Run `2fa -add [account_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -add do in 2fa?
Add a new account. Prompts for the base32-encoded TOTP secret.