Twocli
twocli is a command-line tool in Go for managing 2FA codes. Securely store, generate, update, and delete TOTP for multiple accounts. It encrypts sensitive data using AES-256-GCM with a master password. Ideal for developers and CLI users seeking a lightweight, secure, cross-platform 2FA manager.
Install / Use
/learn @bykclk/TwocliREADME
twocli
twocli is a command-line two-factor authentication (2FA) application written in Go. It allows you to manage and generate Time-based One-Time Passwords (TOTPs) for your accounts securely from the terminal. All secrets are encrypted using AES-256-GCM encryption with a user-provided master password.
Table of Contents
- Features
- Prerequisites
- Installation
- Usage
- Security Considerations
- Examples
- Testing
- License
- Contributing
- Contact
Features
- Add Accounts: Securely store multiple 2FA accounts with names and secrets.
- List Accounts: View all saved account names.
- Generate TOTP Codes: Generate TOTP codes for your accounts with:
- Real-time countdown timer
- Color-coded progress bar
- Automatic code refresh
- Visual remaining time indicator
- Update Accounts: Update the secret key of an existing account.
- Delete Accounts: Remove accounts you no longer need.
- Secure Encryption: All secrets are encrypted using AES-256-GCM with a master password.
- Cross-Platform: Works on Unix-like systems and Windows.
Prerequisites
- Go Programming Language: You need Go installed (version 1.17 or later).
- Download and install Go from golang.org.
Installation
-
Clone the Repository
git clone https://github.com/bykclk/twocli.git cd twocli -
Initialize Go Modules
go mod tidy -
Build the Application
go build -o twocli ./cmd/twocli
Usage
General Syntax:
./twocli [command] [options]
Available Commands
add- Add a new accountlist- List all saved accountscode- Generate TOTP code for an accountupdate- Update the secret key of an existing accountdelete- Delete an existing account
Global Options
-h,--help- Show help information
Add an Account
Add a new account with a name and secret key.
Syntax:
./twocli add -name ACCOUNT_NAME -secret SECRET_KEY
Options:
-name- The name of the account-secret- The base32-encoded secret key for the account
Example:
./twocli add -name GitHub -secret JBSWY3DPEHPK3PXP
List Accounts
List all saved accounts.
Syntax:
./twocli list
Example:
./twocli list
Generate TOTP Code
Generate a TOTP code for a specified account.
Syntax:
./twocli code -name ACCOUNT_NAME [-auto]
Options:
-name- The name of the account-auto- Automatically generate new codes when the current one expires
Example:
# Generate a single code
./twocli code -name GitHub
# Generate codes automatically
./twocli code -name GitHub -auto
Features:
- Color-coded progress bar that changes based on remaining time:
- Green: > 15 seconds
- Yellow: 6-15 seconds
- Red: ≤ 5 seconds
- Visual countdown timer
- Automatic code refresh (with -auto flag)
- Clean and modern UI
Update an Account
Update the secret key of an existing account.
Syntax:
./twocli update -name ACCOUNT_NAME -secret NEW_SECRET_KEY
Options:
-name- The name of the account-secret- The new base32-encoded secret key for the account
Example:
./twocli update -name GitHub -secret NEWSECRETKEY
Delete an Account
Delete an existing account.
Syntax:
./twocli delete -name ACCOUNT_NAME
Options:
-name- The name of the account
Example:
./twocli delete -name GitHub
Security Considerations
- Master Password: A master password is required to encrypt and decrypt your account secrets. Choose a strong, memorable password.
- Password Input: When prompted for your master password, input is hidden for security.
- Encryption: Secrets are encrypted using AES-256-GCM with a key derived from your master password using PBKDF2 with SHA-256 and 100,000 iterations.
- Data Storage: Account data is stored in the
data/accounts.dbfile with restrictive permissions (0600). - Failed Attempts: After 3 incorrect master password attempts, the application will exit to prevent brute-force attacks.
Examples
Adding and Using an Account
-
Add an Account
./twocli add -name Gmail -secret JBSWY3DPEHPK3PXP- Enter your master password when prompted.
-
List Accounts
./twocli list- Enter your master password.
-
Generate TOTP Code
./twocli code -name Gmail- Enter your master password.
- The TOTP code will be displayed.
Updating an Account’s Secret
./twocli update -name Gmail -secret NEWSECRETKEY
- Enter your master password.
Deleting an Account
./twocli delete -name Gmail
- Enter your master password.
- Confirm the deletion by typing
yeswhen prompted.
Testing
The project includes unit tests for critical components.
Running Tests
go test ./...
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please follow these steps:
-
Fork the Repository
Click the “Fork” button at the top right of this page.
-
Clone Your Fork
git clone https://github.com/bykclk/twocli.git -
Create a Branch
git checkout -b feature/your-feature-name -
Commit Your Changes
git commit -am 'Add new feature' -
Push to the Branch
git push origin feature/your-feature-name -
Open a Pull Request
Navigate to the original repository and click “New Pull Request”.
Contact
For questions or support, please open an issue on the GitHub repository.
Disclaimer: Use this tool responsibly. The author is not responsible for any loss of data or security breaches resulting from the use of this application.
Related Skills
node-connect
328.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
81.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
328.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
81.0kCommit, push, and open a PR
