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.
- Features
- Prerequisites
- Installation
- Usage
- Security Considerations
- Examples
- Testing
- License
- Contributing
- Contact
- 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.
- 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.
- Go Programming Language: You need Go installed (version 1.17 or later).
- Download and install Go from golang.org.
-
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
General Syntax:
./twocli [command] [options]
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
-h
,--help
- Show help information
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 all saved accounts.
Syntax:
./twocli list
Example:
./twocli list
Generate a TOTP code for a specified account.
Syntax:
./twocli code -name ACCOUNT_NAME
Options:
-name
- The name of the account
Example:
./twocli code -name GitHub
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 existing account.
Syntax:
./twocli delete -name ACCOUNT_NAME
Options:
-name
- The name of the account
Example:
./twocli delete -name GitHub
- 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.db
file with restrictive permissions (0600
). - Failed Attempts: After 3 incorrect master password attempts, the application will exit to prevent brute-force attacks.
-
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.
./twocli update -name Gmail -secret NEWSECRETKEY
- Enter your master password.
./twocli delete -name Gmail
- Enter your master password.
- Confirm the deletion by typing
yes
when prompted.
The project includes unit tests for critical components.
go test ./...
This project is licensed under the MIT License. See the LICENSE file for details.
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”.
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.