cotp

replydevGPL-3.0活跃维护

命令行双因素认证器,支持 TOTP/HOTP 验证码生成,可加密存储密钥并导入现有认证器数据,适合在终端里管理 2FA。

Encrypted, command-line TOTP/HOTP authenticator app with import functionality.

v1.11.1发布于 2026-10-26 19:23 UTC394star28fork同步于 2026-11-10 06:03 UTC

怎么上手

从 README 代码块原样提取,可能是其中一种安装方式
brew install cotp
git clone https://github.com/replydev/cotp.git
cargo install --path cotp/
硬件要求

README 没有说明硬件要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本v1.11.1
  1. v1.11.1最新正式版2026-10-26 · 2026-10-26 19:23 UTC

    1.11.1 (2026-10-26)

    Bug Fixes

    • ui: allow piped passwords and clarify user messages (01e3ef6)
    • ui: support piped passwords and improve help text (#696) (9450b5f), closes #695
  2. v1.11.02026-10-21 · 2026-10-21 19:57 UTC
    查看更新说明

    1.11.0 (2026-10-21)

    Bug Fixes

    • ui: align digits and simplify account navigation and status (f254986)

    Features

    • ui: revamp dashboard with account forms and mouse support (465c82d)
    • ui: revamp terminal dashboard with account forms and mouse support (#693) (8e8db73)
  3. v1.10.12026-10-21 · 2026-10-21 18:59 UTC
    查看更新说明

    1.10.1 (2026-10-21)

    Bug Fixes

    • prevent database loss when disk is full (197c877)
    • prevent database loss when disk is full (#692) (3c4e17e)
  4. v1.10.02026-07-22 · 2026-07-22 21:34 UTC
    查看更新说明

    1.10.0 (2026-07-22)

    Features

    • import: import Google Authenticator via otpauth-migration URIs (e82ac01)
    • import: import Google Authenticator via otpauth-migration URIs (#674) (e39ae83)
  5. v1.9.102026-05-03 · 2026-05-03 10:19 UTC
    查看更新说明

    1.9.10 (2026-05-03)

    Bug Fixes

    • do not discard time period in TOTP codes (dd6d464)
    • do not discard time period on TOTP codes (#661) (0e74377)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    cotp - command line TOTP/HOTP authenticator

    Actions Status crates.io Downloads

    Packaging status

    I believe that security is of paramount importance, especially in this digital world. I created cotp because I needed a minimalist, secure, desktop accessible software to manage my two-factor authentication codes.

    Overview

    Interface

    Run cotp to open your vault. The dashboard adapts to your terminal, with searchable accounts, a countdown for the selected code, grouped codes, and an account detail panel on wide screens. On your first run, choose a password to initialize the encrypted database.

    Use the keyboard for every action, or click accounts, the search bar, and the visible shortcuts. Keyboard and mouse-wheel navigation stop at the first and last account. The ? menu also offers clickable actions. No special icon font is required. The dashboard needs an interactive terminal; use cotp list or cotp list --json when piping output.

    KeyAction
    ↑ / ↓, k / jSelect an account
    Home / End, PgUp / PgDnFirst / last account, or move ten accounts
    / or Ctrl+FFilter by issuer or account label
    EnterCopy the selected code; on the QR screen, copy its OTP URI
    a / eAdd / edit an account
    SpaceShow or close the selected account's QR code
    hHide / reveal codes
    + / -Increase / decrease an HOTP counter
    d or DeleteDelete an account, with confirmation
    ? or iOpen the shortcuts and actions menu
    EscClose the current screen, finish searching, clear a filter, or quit
    q, Ctrl+C, Ctrl+DQuit; account changes prompt you to save or discard

    Add and edit accounts

    Press a or click Add to enter an issuer, account label, and secret. You can also paste an otpauth:// URI into the secret field to populate the form. Choose the OTP type and algorithm, then adjust digits, period, counter, or PIN as required. Validation focuses the field that needs attention.

    Use Tab / Shift+Tab or ↑ / ↓ to move through fields and buttons. Text fields support cursor movement, Home, End, and Ctrl+U to clear. Click a type or algorithm field, or use ← / → or Space, to change it. Ctrl+S or Save account applies the form; Esc or Cancel discards it. Secret keys and PINs are masked; when editing, leave either blank to keep its existing value.

    Account additions, edits, deletions, and counter changes remain pending until you quit and confirm save. Choosing discard leaves the on-disk vault unchanged. CLI subcommands remain available for scripting; run cotp --help for examples.

    TL;DR

    # Display all the OTP codes in the interactive dashboard
    cotp # select any code with arrow keys, press enter to copy into the clipboard, even in an SSH remote shell
    
    # In the dashboard, press a to add or e to edit an account
    
    # Add a new TOTP code from a BASE32 secret key
    cotp add --label [email protected] --issuer Google
    
    # Add a new HOTP code with custom algorithm, digits and counter
    cotp add --label example --type hotp --algorithm SHA256 --digits 8 --counter 10
    
    # Edit the digits of the 4th OTP code
    cotp edit --index 4 --digits 8
    
    # List all the codes in JSON format passing password through stdin
    echo "mysecretpassword" | cotp --password-stdin list --json
    
    # Extract the first matching OTP code with "google" issuer and copy it into the clipboard
    cotp extract --issuer google --copy-clipboard
    
    # Import an encrypted Aegis Database backup
    cotp import --path my_db.json --aegis-encrypted
    
    # Export the cotp database
    cotp export
    

    Compatibility

    cotp can generate both TOTP and HOTP codes, compliant with rfc6238 and rfc4226 specifications. Also, it is possible to customize settings like HMAC algorithm and digits, to provide compatibility to other two-factor authentication systems.

    Latest releases also include support for Steam, Yandex, MOTP codes.

    Encryption

    This program relies on only one database file encrypted with XChaCha20Poly1305 authenticated encryption and Argon2id for key derivation.

    It also uses AES-GCM to import from encrypted Aegis backups.

    Cross Platform

    cotp should be easily compiled on the most used platforms, but it is mostly tested on Linux, Windows and macOS.

    Install

    Arch Linux / Manjaro / Debian / Ubuntu / NixOS / others...

    cotp is distributed in some of the mayor Linux distro repositories. Please check the repology badge at the top to know if your distribution already provides a package. I will try to push to more repositories over time.

    Otherwise you have other options as explained in the next paragraph.

    Other linux distributions and *nix

    Before beginning check that you have the required build dependencies to use the rust compiler.

    You need to install the libxcb-devel dependency, needed for clipboard coping in X11:

    • Debian based: sudo apt install libxcb1-dev libx11-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev xclip
    • Fedora / RHEL based: sudo dnf install libX11-devel
    • Void Linux sudo xbps-install -S libxcb-devel

    macOS

    brew install cotp
    

    Windows

    Building is supported with both x86_64-pc-windows-gnu and x86_64-pc-windows-msvc toolchains.

    If you want to use x86_64-pc-windows-msvc you will need to install the Visual C++ 2019 Build Tools

    Once you have the rust toolchain installed just run cargo install cotp.

    Use the crates.io repository

    Just type cargo install cotp and wait for the installation.

    Clone the GitHub repository and manually install

    You can build cotp using these commands:

    git clone https://github.com/replydev/cotp.git
    cargo install --path cotp/
    

    Migration from other apps

    cotp supports TOTP codes migration from various apps. Some needs to be converted using simple python script you can find listed in the table below.

    AppHow to fetch backupNeeds conversioncotp argument
    andOTPMake a backup using the app itself.No--andotp
    AegisMake a backup using the app itself.No--aegis
    Aegis (encrypted)Make an encrypted backup using the app itself.No--aegis-encrypted
    AuthyObtain /data/data/com.authy.authy/shared_prefs/com.authy.storage.tokens.authenticator.xml from your phone.Yes--authy
    Authy (2nd method)Follow this guide: https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93.No--authy-exported
    cotpExport your database using cotp export.No--cotp
    FreeOTPObtain /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml from your phone.Yes--freeotp
    FreeOTP+Make a backup using the app itself.No--freeotp-plus
    Google AuthenticatorIn the app open the menu, choose "Transfer accounts" > "Export accounts", select the accounts and let it generate the QR code(s). Scan each QR code with any scanner and save the resulting otpauth-migration://... URI(s), one per line, into a text file.No--google-authenticator
    Microsoft AuthenticatorObtain /data/data/com.azure.authenticator/databases/PhoneFactor from your phone. Take also PhoneFactor-wal, PhoneFactor-shm if they exist in the same folder.Yes--microsoft-authenticator
    OTP URI listCreate a JSON file which contains a items property. It will contains a string array where each element is an OTP URI.No--otp-uri

    How to convert

    Once you got the correct files run the right python script located in the converters/ folder in this source code.

    Example: python authy.py path/to/database.xml converted.json

    It will convert the database in a json format readable by cotp.

    To terminate the import: cotp import --authy --path path/to/converted_database.json

    Configuration

    By default database is located in $HOME/.cotp/db.cotp. If you want to use a different path, you can use COTP_DB_PATH environment variable or use the --database-path argument. The first can be configured in shell configuration files, the second in package managers where the configuration of environment variables is not allowed, like Scoop.

    These are examples of how to do this in bash:

    $ COTP_DB_PATH=/home/user/.local/custom-folder/db.cotp cotp
    

    or

    $ cotp --database-path /home/user/.local/custom-folder/db.cotp
    

    Planned features

    Currently, there is not any planned feature. If you need something new that could improve the software feel free to open an issue.

    Contribution

    I created this project for my own needs, but I would be happy if this little program is useful to someone else, and I gratefully accept any pull requests.

    UI development

    The repository pins Rust and Cargo in rust-toolchain.toml; rustup installs the selected toolchain automatically. The interface uses Ratatui, Crossterm, and tui-input. Rendering and interaction tests cover responsive layouts, keyboard and mouse actions, forms, search, code timing, and masked fields.

    To regenerate the documentation previews from the real widgets and demonstration data:

    COTP_UI_PREVIEW=img/cotp-dashboard.svg COTP_FORM_PREVIEW=img/cotp-editor.svg cargo test interface::tests
    

    To rebuild the animated demo with deterministic example accounts, install ImageMagick (magick) and run:

    python3 ci/render_ui_demo.py
    

    The recording uses the actual dashboard widgets and keyboard/mouse handlers, with synthetic accounts and masked secrets. Tutorial captions appear below the application.