Skip to main content

Command-line application for calculating one-time passwords for 2FA.

Project description

py2fa-cli

PyPI version PePy downloads

Calculates and displays time-based one-time passwords (TOTP) for two-factor authentication:

$ py2fa pypi.org
One-time password: 123456 (valid for 13.7 seconds)

Installation

For typical use:

python3 -m pip install py2fa-cli

For development:

git clone https://github.com/arcctgx/py2fa-cli
cd py2fa-cli
python3 -m pip install --editable .

Dependencies

  • pyotp
  • pyxdg

These dependencies will be installed automatically when py2fa-cli is installed by pip.

Configuration

TOTP secrets are stored in user's XDG configuration directory. Unless you changed your XDG_CONFIG_HOME, that will be .config/py2fa/secrets.json in your $HOME. The secrets file must not be world-accessible (readable, writable or executable): in such case py2fa will refuse to load it.

The secrets file is a dictionary represented in JSON format, e.g.:

{
    "pypi.org": "MYPYPITOTPSECRET",
    "test.pypi.org": "MYTESTPYPITOTPSECRET"
}

The dictionary key is what you provide in the command-line, so just use any name that's convenient. The value is the shared TOTP secret in base32 format.

A note for Microsoft Authenticator users

It is not possible to extract the shared secret from the Microsoft Authenticator application once it's been configured. You can only obtain the shared secret when you first set up the authenticator app.

When presented with a QR code, do not scan it with Microsoft Authenticator. Instead use some generic QR scanner app. You should get an URI similar to this one:

otpauth://totp/YourOrg%3Ayour.email%40your.org?secret=TWOJDZIENTWOJAWODA&issuer=Microsoft

Extract the secret from the URI and put it in your secrets.json file. If you want to, you can scan the QR code with Microsoft Authenticator now. py2fa and the authenticator app will generate the same TOTP codes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py2fa-cli-1.0.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

py2fa_cli-1.0.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file py2fa-cli-1.0.1.tar.gz.

File metadata

  • Download URL: py2fa-cli-1.0.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.2

File hashes

Hashes for py2fa-cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6a91766b8dbc1131bfadf19747d0e2cec52ece1d8d704de6358407c5ad4b1392
MD5 8b903ccdd2533bbcd92b3ec1c7ea9617
BLAKE2b-256 1b33daa8884d3935ce12697cd2529706a83987ba16388952bd679af9eab2ce27

See more details on using hashes here.

File details

Details for the file py2fa_cli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: py2fa_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.2

File hashes

Hashes for py2fa_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2c7aaebcaf92539373c2d1f90a61e7eafe8f7661f55c47604c999ad2e742bff
MD5 7b74c1074dda8d1393082ca36e6f2a88
BLAKE2b-256 ab7e95a6a40d8e9d412ad552bd98cfd3f5c3e821e214ecd3ce90ec2289a6a82e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page