Implement and configure alternative authentication.
Outcomes
Manage standard vaults and secrets.
Authenticate to the IdM API from the command line.
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-review
Instructions
Install the Key Recovery Authority (KRA) component on the idm machine.
Log in to the idm machine as student and become the root user:
[student@workstation ~]$ssh idm[student@idm ~]$sudo -i[sudo] password for student:student
Install the KRA component:
If you have already installed the KRA component on the idm machine, then the command fails with the KRA already installed message.
[root@idm ~]#ipa-kra-installDirectory Manager password:RedHat123^=================================================================== This program will setup Dogtag KRA for the IPA Server. Configuring KRA server (pki-tomcatd). Estimated time: 2 minutes [1/9]: configuring KRA instance [2/9]: create KRA agent [3/9]: enabling ephemeral requests [4/9]: restarting KRA [5/9]: configure certmonger for renewals [6/9]: configure certificate renewals [7/9]: add vault container [8/9]: apply LDAP updates [9/9]: enabling KRA instance Done configuring KRA server (pki-tomcatd). Restarting the directory server The ipa-kra-install command was successful
On the client machine, create the prod-files standard vault and store the /home/student/database.kdbx file as a secret.
Open a new terminal tab and log in to the client machine as the student user.
Authenticate to IdM as the idmuser01 user:
[student@workstation ~]$ssh client[student@client ~]$kinit idmuser01Password for idmuser01@LAB.EXAMPLE.COM:RedHat123^
Review the details of the /home/student/database.kdbx file.
Notice specifically the access and modification dates:
[student@client ~]$ stat database.kdbx
File: database.kdbx
Size: 65536 Blocks: 128 IO Block: 4096 regular file
Device: fc04h/64516d Inode: 8497822 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2023-06-28 17:32:32.849982303 -0400
Modify: 2023-06-28 17:32:32.849982303 -0400
Change: 2023-06-28 17:32:32.849982303 -0400
Birth: 2023-06-28 17:32:32.849982303 -0400Create the prod-files standard vault:
[student@client ~]$ ipa vault-add prod-files --type standard
----------------------
Added vault "prod-files"
----------------------
Vault name: prod-files
Type: standard
Owner users: idmuser01
Vault user: idmuser01Store the /home/student/database.kdbx file:
[student@client ~]$ ipa vault-archive prod-files --in ~/database.kdbx
-----------------------------------
Archived data into vault "prod-files"
-----------------------------------On the idm machine, retrieve the secret stored in the prod-files vault.
Switch to the first terminal tab and log out of the root user.
Authenticate to IdM as the idmuser01 user:
[root@idm ~]#logout[student@idm ~]$kinit idmuser01Password for idmuser01@LAB.EXAMPLE.COM:RedHat123^
Retrieve the secret stored in the prod-files vault:
[student@idm ~]$ ipa vault-retrieve prod-files --out ~/database.kdbx
------------------------------------
Retrieved data from vault "prod-files"
------------------------------------Review the details for the /home/student/database.kdbx file.
Note that the size matches the original file, but the modification time is the time that the secret was retrieved. Only the content of the file is stored in the vault, not the file itself:
[student@idm ~]$ stat database.kdbx
File: database.kdbx
Size: 65536 Blocks: 128 IO Block: 4096 regular file
Device: fc04h/64516d Inode: 8498112 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ student) Gid: ( 1000/ student)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2023-06-28 17:46:07.347438594 -0400
Modify: 2023-06-28 17:46:07.347438594 -0400
Change: 2023-06-28 17:46:07.347438594 -0400
Birth: 2023-06-28 17:46:07.347438594 -0400Authenticate to IdM as the admin user, and configure two-factor authentication for the idmuser05 user.
Authenticate as the admin user:
[student@idm ~]$kinit adminPassword for admin@LAB.EXAMPLE.COM:RedHat123^
Configure two-factor authentication for the idmuser05 user:
[student@idm ~]$ ipa user-mod idmuser05 --user-auth-type=otp
-------------------------
Modified user "idmuser05"
-------------------------
User login: idmuser05
First name: idmuser05
Last name: idm
Home directory: /home/idmuser05
Login shell: /bin/sh
Principal name: idmuser05@LAB.EXAMPLE.COM
Principal alias: idmuser05@LAB.EXAMPLE.COM
Email address: idmuser05@example.com
UID: 739000013
GID: 739000013
User authentication types: otp
Account disabled: False
Password: True
Member of groups: ipausers
Kerberos keys available: TrueOn 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.
On the idm machine, create a user-managed software token.
Set otp as the description and set idmuser05 as the user.
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.
On the workstation machine, open a 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.
In the IdM web UI, log in as the idmuser05 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 . The passcode is only valid for brief period of time, so if authentication fails, try generating a new passcode.
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
350759Enter the generated passcode at the end of the password, and then click .
Log out of the web UI and exit the SSH session to the client and idm machines.