A Python script for generating OTP codes
Project description
py_oathtool2
py_oathtool2 is a Python script for easy OTP code generation on the command line for use with scripting or simply as a convenience.
Installation
pip install py_oathtool2
Dependencies
py_oathtool2 automatically copies codes to the clipboard. This depends on the following programs being installed:
- Linux with X11:
xclip - Linux with Wayland:
wl-copy - MacOS:
pbcopy(installed by default)
Configuration
Two pieces of information are required for each account:
- An account name / label
- Your 64 character oath secret provided by the 3rd party. This is typically a QR code, but websites often also offer the string.
The script will read these values from a config file sourced from, by default, ~/.otp-secrets.yaml in the following format:
otpsecrets:
github: IOOVV6U5AUHUISZKJNVCCG4JWUR5XDFSI7ND62A7QT5ZOEVYVA7JEEDKTG3ZM57B
aws-account-dev: XQYNZOIA4PWCTJCB9654EQP5LUIP23BOW6J5ZIRZZSDHK24AUEDUSCONP3KQQY4N
aws-account-prod: 57QPXJFJ4D2ILQBRZGSHKAZCJ2Y46C52FGVSZRYMY7UMWTIQI6I3GOJQZ4VJN2R4
Additionally, the following configuration options are supported in the ~/.otp-secrets.yaml file:
holdoff: Specify a different holdoff value to wait for the next codeuse_clipboard: Disable putting the code on the clipboard
Usage
List all configured accounts with -l:
$ otp -l
github
aws-account-dev
aws-account-prod
Generate an OTP by providing the account name. The script will provide the OTP code and also put it on the clipboard:
$ otp aws-account-dev
129987 (10sec)
See all arguments with:
$ otp --help
Shell Autocompletion
Autocompletion support can be added through use of the -t flag.
For zsh support, add the following to your .zshrc file:
compdef _otp otp
_otp() {
compadd `otp -t`
}
Development
After cloning use pipenv to install dependencies and run the script:
pipenv install
pipenv run python src/py_oathtool2/otp.py [args]
Running Tests
pipenv run python -m unittest test/test_otp.py
Building & Installing
pipenv run python -m build
pip install --force-reinstall dist/py_oathtool2-*.whl
Upload to PyPI
pipenv run python -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
Disclaimer
Two factor auth is meant to provide an extra layer of account security and this tool does not exactly promote that concept. You are responsible for taking reasonable steps to protect your secrets file to prevent loss of secrets, and perhaps this is not the ideal two factor solution for your most important accounts.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_oathtool2-1.2.0.tar.gz.
File metadata
- Download URL: py_oathtool2-1.2.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4a7a56e98883328d17834222dc531e5d8416c75eef3c26e45ab87a533120e55
|
|
| MD5 |
caa1fbf78ee84f697fcb9cdc2b080731
|
|
| BLAKE2b-256 |
411d6b07891f11f157c94dfa60cc811d971b4613b2b6385432285ab65e8f327a
|
File details
Details for the file py_oathtool2-1.2.0-py3-none-any.whl.
File metadata
- Download URL: py_oathtool2-1.2.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e46ef4cd7a2dfb74f94759a762cb2f898e1e91f6f116359df5c42a4e686ff1fa
|
|
| MD5 |
542b6c58b0de280ee8169f3fdc97dd27
|
|
| BLAKE2b-256 |
9e9101fb4dbdc71b197b5863f42ad77e4135961379c4a7572465354b14d4e9ca
|