1. Home
  2. Linux
  3. Generate two factor authentication codes on linux authenticator

How To Generate Two Factor Authentication Codes On Linux With Authenticator

Two-factor authentication is nice, but it’s irritating having to deal with random text messages every time you try to log in. If you’re looking for a better way to use 2FA, consider trying out Authenticator. It’s an application that users can set up to get two factor authentication codes on Linux.

Note: To install this software, you’ll need to be able to use Flatpak.

Flatpak Installation

The easiest way to install Authenticator on Linux is to use the Flatpak version, as it doesn’t require any configuration aside from installing the Flatpak runtime. If your Linux distribution supports Flatpak technology, you can easily install the Authenticator app.

Before continuing, be sure you already have Flatpak working on your Linux PC. Head over to our tutorial and follow the instructions to learn how to do this if you are unsure. When Flatpak is working correctly, you’ll be able to install Authenticator via the terminal.

sudo flatpak install flathub com.github.bilelmoussaoui.Authenticator

Need to uninstall Authenticator from Flatpak? Try:

sudo flatpak remove com.github.bilemoussaoui.Authenticator

Source Installation

Clearly installing this application via Flatpak is the best choice, as users will deal with the least amount of hassle. However, for as great as the Flatpak runtime is, not every Linux distribution actively supports it. If you’re running a version of Linux that doesn’t, you’ll need to build this software from source.

To build from source, open up a terminal and install the following dependencies. Keep in mind that these dependencies may differ, depending on your operating system. For best results, search your package manager for the items on the list below:

  • Gtk 3.16+
  • meson 0.38+
  • ninja
  • python3-pip
    • python-pip (Arch)
  • pyotp
  • Pillow
  • pyzbar
    • libzbar-dev (Ubuntu)
    • zbar (Arch)
  • libsecret
  • zbar
  • git

After installing all required dependency files, Authenticator is ready to build. First, use the Git tool to clone the latest version of the Authenticator source code from Github.

git clone https://github.com/bilelmoussaoui/Authenticator

Next, use the CD command to move from the Home folder into the newly cloned Authenticator folder.

cd Authenticator

Inside of the Authenticator folder, use Python Pip to install important Packages.

sudo pip install pyotp pyzbar Pillow meson ninja

Using Meson, start the building process:

meson builddir

Finish up the building process with Ninja.

sudo ninja -C builddir install

Run Authenticator with:

authenticator

Set Up Authenticator

Using Authenticator is done on a per-site basis. There’s no way to set the app up to work with every site. Instead, you’ll have to dig into the security settings of every account and get it working with two-factor-authentication. In this example, we’ll go over how to configure the Authenticator app to work with Amazon.

The instructions outlined with this app are very straightforward and can be duplicated with pretty much every website that is supported by the app.

To get started, open up Authenticator, click the search icon and search for “Amazon”. After opening Amazon in the Authenticator app, open up a web browser and log into your Amazon.com account.

On the Amazon website, hover over “Account & Lists”, then select the “Your Account” option in the drop-down menu.

In the “Your Account” area, look for “Login & security” and click on it.

The “Login & security” area of Amazon.com houses everything related to logging in, email info and etc. Find the option that says “Advanced Security Settings”, and click on it.

On the next page, Amazon will brief you on what 2FA login can do for your account, how it works and etc. Be sure to read over it carefully. When ready, click the “get started” button to move onto the activation page.

Amazon.com’s 2FA settings allow the user to get secret codes from a text sent to a mobile device. Alternatively, users can set up an authentication app. Ignore the phone settings, look for Authenticator App and check the box next to it to enable this feature for your account.

Enabling 2FA within your Amazon account will generate a scannable QR code. At this point, go back to Authenticator, ensure you have Amazon open in it, and click the QR icon in the top-right corner to activate scanning mode.

With scanning mode enabled in Authenticator, go back to the Amazon 2FA page and use your mouse to draw a square around the QR code.

Note: if scanning the QR code doesn’t work in Authenticator, select the “can’t scan QR code” option, and paste the text code it gives you into Authenticator instead.

If Authenticator successfully reads the QR image, it’ll generate a code. Enter the code into the “verify” box.

From now on when you log into Amazon (or any site linked to Authenticator), follow this process:

  1. Go to the website and enter username/password.
  2. Open Authenticator, search for the correct site and copy the generated code.
  3. Paste the code into the web page to log in.

3 Comments

  1. That’s way too much for a simple thing.
    In ubuntu.
    sudo apt install oathtool

    Then when you enable 2FA on any site, record the “Secret key” they give you.
    To generate your tokens.
    oathtool -b –totp

    You can even setup an alias.
    alias token1=’oathtool -b –totp | xsel –clipboard’
    And so on.
    You type token1 in your terminal the token is automatically copied to your clipboard.