I would like to introduce the python script that generate OTP from MFA key that you provide from CLI.
First of all, install python3, for example:
$ brew install python3NOTE: You have to install HOMEBREW, the command here:
$ sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"Secondly, installing PIP:
$ sudo easy_install pipAfter that, install requiriments:
$ pip3.7 install -r requirements.txtTo get a help, run:
$ python3 get_OTP.py --help
usage: python3 script_name.py {ARGS}
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
--acc ACCOUNT Account name
--path PATH Path to .aws/credentials file
--show-acc Show account names
created by Vitalii NatarovTo use this py-script, run the next command:
$ python3 get_OTP.py --acc aws-acc
Please add [aws-acc] account to /Users/captain/.aws/credentials
EXAMPLE:
[aws-acc]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = YYYYYYYYYYYYYYYYYYYYYYYY
region = us-east-1
mfa_authorisation_key = ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
You can use the following ones: ['default', 'LinuxNotes', 'test', 'test-long-term']As can you see, the AWS account does not exist. Add all needs to the ~/.aws/credentials file to generate OTP. When you're having set up an account and will run the command, you can see the next result:
$ python3 get_OTP.py --acc aws-acc
Current OTP for aws-acc: 034480I would like to optimize that script to work with other scripts that use OTP by automatically way and put additional functionality.
Of course, you can add alias for this script, for example:
$ echo 'alias get_OTP="python3 /Users/captain/Projects/python/pyotp/get_OTP.py"' >> ~/.zshrcCreated and maintained by Vitaliy Natarov. An email: vitaliy.natarov@yahoo.com.
Apache 2 Licensed. See LICENSE for full details.