hpr4503 :: One time passwords using oathtool

This podcast is about using one time passwords by means of "oathtool"

Hosted by Whiskeyjack on Wednesday, 2025-11-05 is flagged as Clean and is released under a CC-BY-SA license.
OATH, oathtool. 2.

Listen in ogg, opus, or mp3 format. Play now:

Duration: 00:13:09
Download the transcription and subtitles.

general.

Oathtool


06 OATH Options and Oathtool

The OATH standard has several options.

You need to know which OATH options the site you wish to log into uses in order to use OATH.


07 Options - TOTP versus HOTP

There are two different types of OATH one time passwords, HOTP and TOTP.

HOTP uses a counter. 

I won't go into more detail on HOTP as I haven't come across anyone using it.

TOTP uses the current time instead of a counter.

The time is fed into the OATH algorithm along with the shared secret to generate a new password on both ends of the connection.

All the instances of OATH that I am familiar with use TOTP.


08 TOTP Mode

Totp has different "modes".

These modes are hash encoding algorithms such as SHA1, SHA256, or SHA512.

The correct mode must be selected in order to log in using OATH with TOTP.


09 Encoding - Hex versus Base32

Both ends of the connection must be initialized with a shared secret or key which is required as part of the OATH algorithm.

This key could be encoded in one of two forms, either hexadecimal or base32.

Web sites often do not document which encoding method they are using.

If you cannot determine the encoding of the key by simply looking at it you may need to use trial and error during your first OATH log in attempts to see which type of key has been used.


10 Github and Pypi Options

Github and Pypi are two of the most prominent web sites using OATH.

Both use the same options, TOTP with SHA1 mode, and base32 encoding.



11 Using Oathtool

oathtool is a simple command line application which generates one time passwords for use with OATH.

It can be run in a terminal.

However, can also be turned into a simple GUI application using Zenity. Will discuss this in more detail later.

By default oathtool uses hotp and hex encoding.

To use totp and base32 encoding you must specify these on the command line.

To specify base32 encoding for use with for example Github, pass the "-b" or "--base32" argument on the command line.

To specify TOTP, pass the "--totp" argument on the command line.

By default, oathtool uses SHA1 with totp, so you don't need to specify that if you require SHA1.

If you need a different TOTP mode, you specify that as part of the TOTP argument separated by an "=" character. For example "--totp=SHA256".


12 Oathtool Example

Here is a simple example of using oathtool to create a one time password to use with Github or Pypi.

Open a terminal and type the following.


oathtool -b --totp SOMEBIGBASE32SECRETCODE


The one time password will be printed out in the terminal.

You can try this out without using a valid key so long as it is a valid base32 string.

When used with a valid key you then enter that one time password into Github, Pypi, or other web site where it asks for the one time password.

Note that I have not covered in the above how to store and retrieve the key securely, as that is too big of a topic to cover here. 



13 Zenity Example

Oathtool is a command line application, but if you are using Linux it is simple to convert it into a GUI application by using "Zenity".

Zenity is a simple to use package that creates GUI windows on the command line or in a shell script.

There are two steps to the proceess.

First create the OTP from the key by using oathtool and save it in a variable.

Next, call a Zenity "info" window with the OTP as part of the provided text.

You can now copy and paste the OTP from the window into your web browser.

To close the window, click on the "OK" button.

See the previous note on storing the key securely. 


hprcode=$(oathtool -b --totp SOMEBIGBASE32SECRETCODE)

zenity --info --width=150 --title="HPR 2FA" --text="<big>2FA code is:</big> \n\n $hprcode \n"


If you are using Gnome you can make the script launchable from the desktop by creading a ".desktop" file in the "Desktop" directory.




Comments

Subscribe to the comments RSS feed.

Comment #1 posted on 2025-11-10 13:30:48 by interesting, but...

candycanearter07

I think it's really cool that you can generate OTP's locally, and I'm a bit annoyed that companies don't let you do this in the first place, but I think it would be a bit impractical for me to actually use daily, since you'd need to figure out the secret code for each website individually, as well as which sha version they're using.

Also, theres a pretty easy way to automatically copy the code to the clipboard, its something I use a lot in my own scripts:

printf $CODE | xclip -selection c

(using printf to remove the leading newline)

Comment #2 posted on 2025-11-11 23:30:43 by Whiskeyjack

One time passwords using oathtool

@candycanearter07 - Using oathtool OTP is no different from using a special smartphone OTP app. Both follow the Oath standard.

The reason that I started using oathtool was because Github and Pypi made OTPs mandatory. After putting it off as long as possible I was determined to find a solution that didn't involve giving either of them a phone number to send an SMS to or to install their OTP app. I thought there must be a way to do this with a free software application on my PC, and there was. It just took a bit of digging to figure it out.

Any website that uses an Oath standard OTP will have some sort of key that they need to give to you, typically by going to a web page where you generate one after logging in. It's not any more difficult than say changing your password and you only have to do this once for each site.

The main issue is as said, Github and Pypi at least did not document their Oath options, or at least they didn't when I started using it a while ago.

Anyone who wants to use oathtool for Github or Pypi though now knows what options are needed after having listened to this podcast episode.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the letter P in HPR stand for?