Bookmark this page

Guided Exercise: Implementing Two-factor Authentication

Configure one-time password (OTP) authentication and test it on a server configured to use OTP.

Outcomes

  • Verify Kerberos single sign-on.

  • Configure one-time password authentication.

As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available:

[student@workstation ~]$ lab start alternative-twofactor

Note

This exercise requires the use of either an Android or iPhone smartphone. To configure one-time passwords, you need to install an external Red Hat sponsored application, or a QR code scanning application if you do not have one. If you do not wish to install anything on your mobile device, consider this exercise as concluded and perform the cleanup task.

Instructions

  1. Log in to the idm machine, and request a Kerberos ticket as the admin user with RedHat123^ as the password:

    [student@workstation ~]$ ssh idm
    [student@idm ~]$ kinit admin
    Password for admin@LAB.EXAMPLE.COM: RedHat123^
  2. Configure two-factor authentication for the idmuser02 user:

    [student@idm ~]$ ipa user-mod idmuser02 --user-auth-type=otp
    -------------------------
    Modified user "idmuser02"
    -------------------------
      User login: idmuser02
      First name: idmuser02
      Last name: idm
      Home directory: /home/idmuser02
      Login shell: /bin/sh
      Principal name: idmuser02@LAB.EXAMPLE.COM
      Principal alias: idmuser02@LAB.EXAMPLE.COM
      Email address: idmuser02@example.com
      UID: 12400003
      GID: 12400003
      User authentication types: otp
      Account disabled: False
    ...output omitted...
  3. On your mobile device, search for and install the FreeOTP Authenticator application.

    If you choose not to install FreeOTP on your mobile devices, an alternative method using any QR code scanner is provided.

  4. On the idm machine, create the user-managed software token. Set phone as the description and set idmuser02 as the user:

    [student@idm ~]$ ipa otptoken-add --desc=phone --owner=idmuser02
  5. Scan the displayed QR code with FreeOTP to provision the token to the mobile device.

    As an alternative, use a QR code scanner to scan the QR code.

  6. On the workstation machine, open the web browser and navigate to https://idm.lab.example.com. If you are automatically logged in to the IdM web UI, log out of the dashboard.

  7. In the IdM web UI, log in as the idmuser02 user. For the password, enter the user password followed by a FreeOTP passcode.

    For the first part, enter RedHat123^. For the second part, use FreeOTP to generate a passcode. The two items combined form the one-time password (OTP).

    Click Login. The passcode is only valid for a brief period of time, so if authentication fails, try generating a new passcode.

    Note

    If you used the QR scanner, use the oathtool --base32 --totp command to generate the required passcode. In the URI displayed on your mobile device, find the secret= value and use that string as the argument for the --totp option. Run the following command on the workstation machine:

    [student@workstation ~]$ oathtool --base32 \
      --totp CODE
    350759

    Enter the generated passcode at the end of the password, and then click Login.

  8. Log out of the web UI and exit the idm machine:

    [student@idm ~]$ exit
    logout
    Connection to idm closed.

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish alternative-twofactor

Revision: rh362-9.1-4c6fdb8