RHEL 8.5 - Managing Smart Card Authentication
RHEL 8.5 - Managing Smart Card Authentication
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons
Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is
available at
http://creativecommons.org/licenses/by-sa/3.0/
. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must
provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert,
Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift,
Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States
and other countries.
Linux ® is the registered trademark of Linus Torvalds in the United States and other countries.
XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States
and/or other countries.
MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and
other countries.
Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the
official Joyent Node.js open source or commercial project.
The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks
or trademarks/service marks of the OpenStack Foundation, in the United States and other
countries and are used with the OpenStack Foundation's permission. We are not affiliated with,
endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
Abstract
This documentation collection provides instructions on how to manage smart card authentication in
RHEL.
Table of Contents
Table of Contents
. . . . . . . . . .OPEN
MAKING . . . . . . SOURCE
. . . . . . . . . .MORE
. . . . . . .INCLUSIVE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . .
. . . . . . . . . . . . . FEEDBACK
PROVIDING . . . . . . . . . . . . ON
. . . .RED
. . . . .HAT
. . . . .DOCUMENTATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5. . . . . . . . . . . . .
.CHAPTER
. . . . . . . . . . 1.. .CONFIGURING
. . . . . . . . . . . . . . . .IDENTITY
. . . . . . . . . . MANAGEMENT
. . . . . . . . . . . . . . . . .FOR
. . . . .SMART
. . . . . . . .CARD
. . . . . . AUTHENTICATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6. . . . . . . . . . . . .
1.1. CONFIGURING THE IDM SERVER FOR SMART CARD AUTHENTICATION 6
1.2. CONFIGURING THE IDM CLIENT FOR SMART CARD AUTHENTICATION 8
1.3. ADDING A CERTIFICATE TO A USER ENTRY IN THE IDM WEB UI 10
1.4. ADDING A CERTIFICATE TO A USER ENTRY IN THE IDM CLI 11
1.5. INSTALLING TOOLS FOR MANAGING AND USING SMART CARDS 12
1.6. STORING A CERTIFICATE ON A SMART CARD 13
1.7. LOGGING IN TO IDM WITH SMART CARDS 14
1.8. CONFIGURING GDM ACCESS USING SMART CARD AUTHENTICATION 16
1.9. CONFIGURING SU ACCESS USING SMART CARD AUTHENTICATION 16
. . . . . . . . . . . 2.
CHAPTER . . CONFIGURING
. . . . . . . . . . . . . . . . CERTIFICATES
. . . . . . . . . . . . . . . . ISSUED
. . . . . . . . BY
. . . .ADCS
. . . . . . FOR
. . . . . SMART
. . . . . . . . CARD
. . . . . . .AUTHENTICATION
. . . . . . . . . . . . . . . . . . . .IN
. . IDM
.................
18
2.1. SMART CARD AUTHENTICATION 18
2.2. WINDOWS SERVER SETTINGS REQUIRED FOR TRUST CONFIGURATION AND CERTIFICATE USAGE 19
2.3. COPYING CERTIFICATES FROM ACTIVE DIRECTORY USING SFTP 19
2.4. CONFIGURING THE IDM SERVER AND CLIENTS FOR SMART CARD AUTHENTICATION USING ADCS
CERTIFICATES 20
2.5. CONVERTING THE PFX FILE 21
2.6. INSTALLING TOOLS FOR MANAGING AND USING SMART CARDS 22
2.7. STORING A CERTIFICATE ON A SMART CARD 23
2.8. CONFIGURING TIMEOUTS IN SSSD.CONF 24
2.9. CREATING CERTIFICATE MAPPING RULES FOR SMART CARD AUTHENTICATION 25
. . . . . . . . . . . 3.
CHAPTER . . CERTIFICATE
. . . . . . . . . . . . . . .MAPPING
. . . . . . . . . . .RULES
. . . . . . . FOR
. . . . . CONFIGURING
. . . . . . . . . . . . . . . . AUTHENTICATION
. . . . . . . . . . . . . . . . . . . .ON
. . . .SMART
. . . . . . . .CARDS
.......................
26
3.1. CERTIFICATE MAPPING RULES FOR TRUSTS WITH ACTIVE DIRECTORY DOMAINS 26
3.2. COMPONENTS OF AN IDENTITY MAPPING RULE IN IDM 27
3.3. OBTAINING THE ISSUER FROM A CERTIFICATE FOR USE IN A MATCHING RULE 28
3.4. ADDITIONAL RESOURCES 29
.CHAPTER
. . . . . . . . . . 4.
. . .CONFIGURING
. . . . . . . . . . . . . . . .AND
. . . . .IMPORTING
. . . . . . . . . . . . .LOCAL
. . . . . . . CERTIFICATES
. . . . . . . . . . . . . . . . TO
. . . .A. .SMART
. . . . . . . .CARD
. . . . . . . . . . . . . . . . . . . . . . .30
..............
4.1. CREATING LOCAL CERTIFICATES 30
4.2. COPYING CERTIFICATES TO THE SSSD DIRECTORY 33
4.3. INSTALLING TOOLS FOR MANAGING AND USING SMART CARDS 34
4.4. STORING A CERTIFICATE ON A SMART CARD 34
4.5. CONFIGURING SSH ACCESS USING SMART CARD AUTHENTICATION 36
.CHAPTER
. . . . . . . . . . 5.
. . CONFIGURING
. . . . . . . . . . . . . . . . SMART
. . . . . . . . CARDS
. . . . . . . . USING
. . . . . . . .AUTHSELECT
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
..............
5.1. CERTIFICATES ELIGIBLE FOR SMART CARDS 39
5.2. ENABLING USER PASSWORD AUTHENTICATION TO CONFIGURE SMART CARD AUTHENTICATION 39
5.3. CONFIGURING AUTHSELECT TO ENFORCE SMART CARD AUTHENTICATION 40
5.4. CONFIGURING SMART CARD AUTHENTICATION WITH LOCK ON REMOVAL 40
.CHAPTER
. . . . . . . . . . 6.
. . .AUTHENTICATING
. . . . . . . . . . . . . . . . . . . TO
. . . .SUDO
. . . . . . .REMOTELY
. . . . . . . . . . . .USING
. . . . . . . SMART
. . . . . . . . CARDS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
..............
6.1. CREATING SUDO RULES IN IDM 42
6.2. SETTING UP THE PAM MODULE FOR SUDO 43
6.3. CONNECTING TO SUDO REMOTELY USING A SMART CARD 43
. . . . . . . . . . . 7.
CHAPTER . . TROUBLESHOOTING
. . . . . . . . . . . . . . . . . . . . . . .AUTHENTICATION
. . . . . . . . . . . . . . . . . . . .WITH
. . . . . .SMART
. . . . . . . .CARDS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
..............
1
Red Hat Enterprise Linux 8 Managing smart card authentication
2
Table of Contents
3
Red Hat Enterprise Linux 8 Managing smart card authentication
The word master is being replaced with more precise language, depending on the context:
4
PROVIDING FEEDBACK ON RED HAT DOCUMENTATION
1. Make sure you are viewing the documentation in the Multi-page HTML format. In addition,
ensure you see the Feedback button in the upper right corner of the document.
2. Use your mouse cursor to highlight the part of text that you want to comment on.
3. Click the Add Feedback pop-up that appears below the highlighted text.
3. Fill in the Description field with your suggestion for improvement. Include a link to the
relevant part(s) of documentation.
5
Red Hat Enterprise Linux 8 Managing smart card authentication
This user story shows how to set up smart card authentication in IdM for both types of certificates. In
the user story, the smartcard_ca.pem CA certificate is the file containing the certificate of a trusted
external certificate authority.
To enable smart card authentication for IdM users who have been issued a certificate by the IdM
Certificate Authority, obtain the CA certificate from the /etc/ipa/ca.crt file on the IdM server on which
the IdM CA is running.
This section describes how to configure an IdM server for smart card authentication. First, obtain files
with the CA certificates in the PEM format, then run the in-built ipa-advise script. Finally, reload the
system configuration.
6
CHAPTER 1. CONFIGURING IDENTITY MANAGEMENT FOR SMART CARD AUTHENTICATION
Prerequisites
Procedure
[root@server]# cd ~/SmartCard/
3. Obtain the relevant CA certificates stored in files in PEM format. If your CA certificate is stored
in a file of a different format, such as DER, convert it to PEM format. The IdM Certificate
Authority certificate is located in the /etc/ipa/ca.crt file.
Convert a DER file to a PEM file:
# openssl x509 -in <filename>.der -inform DER -out <filename>.pem -outform PEM
4. For convenience, copy the certificates to the directory in which you want to do the
configuration:
5. Optionally, if you use certificates of external certificate authorities, use the openssl x509 utility
to view the contents of the files in the PEM format to check that the Issuer and Subject values
are correct:
6. Generate a configuration script with the in-built ipa-advise utility, using the administrator’s
privileges:
It enables Public Key Cryptography for Initial Authentication in Kerberos (PKINIT) on the
Key Distribution Center (KDC).
7. Execute the script, adding the PEM files containing the root CA and sub CA certificates as
arguments:
7
Red Hat Enterprise Linux 8 Managing smart card authentication
NOTE
Ensure that you add the root CA’s certificate as an argument before any sub CA
certificates and that the CA or sub CA certificates have not expired.
8. Optionally, if the certificate authority that issued the user certificate does not provide any
Online Certificate Status Protocol (OCSP) responder, you may need to disable OCSP check for
authentication to the IdM Web UI:
SSLOCSPEnable off
b. Restart the Apache daemon (httpd) for the changes to take effect immediately:
WARNING
Do not disable the OCSP check if you only use user certificates issued by
the IdM CA. OCSP responders are part of IdM.
For instructions on how to keep the OCSP check enabled, and yet prevent a user certificate
from being rejected by the IdM server if it does not contain the information about the location at
which the CA that issued the user certificate listens for OCSP service requests, see the
SSLOCSPDefaultResponder directive in Apache mod_ssl configuration options .
NOTE
To enable smart card authentication in the whole topology, run the procedure on each
IdM server.
8
CHAPTER 1. CONFIGURING IDENTITY MANAGEMENT FOR SMART CARD AUTHENTICATION
to be run on each IdM system, a client or a server, to which you want to connect while using a smart card
for authentication. For example, to enable an ssh connection from host A to host B, the script needs to
be run on host B.
the su command
This procedure is not required for authenticating to the IdM Web UI. Authenticating to the IdM Web UI
involves two hosts, neither of which needs to be an IdM client:
the machine - possibly outside of the IdM domain - on which the browser is running
The following procedure assumes that you are configuring smart card authentication on an IdM client,
not an IdM server. For this reason you need two computers: an IdM server to generate the configuration
script, and the IdM client on which to run the script.
Prerequisites
Your IdM server has been configured for smart card authentication, as described in Configuring
the IdM server for smart card authentication.
You have root access to the IdM server and the IdM client.
You have access to the root CA certificate and any sub CA certificates.
You installed the IdM client with the --mkhomedir option to ensure remote users can log in
successfully. If you do not create a home directory, the default login location is root.
Procedure
1. On an IdM server, generate a configuration script with ipa-advise using the administrator’s
privileges:
It configures the System Security Services Daemon (SSSD) to allow smart card logins to the
desktop.
9
Red Hat Enterprise Linux 8 Managing smart card authentication
2. From the IdM server, copy the script to a directory of your choice on the IdM client machine:
3. From the IdM server, copy the CA certificate files in the PEM format for convenience to the
same directory on the IdM client machine as used in the previous step:
4. On the client machine, execute the script, adding the PEM files containing the CA certificates as
arguments:
NOTE
Ensure that you add the root CA’s certificate as an argument before any sub CA
certificates and that the CA or sub CA certificates have not expired.
Instead of uploading the whole certificate, it is also possible to upload certificate mapping data to a user
entry in IdM. User entries containing either full certificates or certificate mapping data can be used in
conjunction with corresponding certificate mapping rules to facilitate the configuration of smart card
authentication for system administrators. For details, see Certificate mapping rules for configuring
authentication on smart cards.
NOTE
If the user’s certificate has been issued by the IdM Certificate Authority, the certificate is
already stored in the user entry, and you can skip this section.
Prerequisites
You have the certificate that you want to add to the user entry at your disposal.
10
CHAPTER 1. CONFIGURING IDENTITY MANAGEMENT FOR SMART CARD AUTHENTICATION
Procedure
1. Log into the IdM Web UI as an administrator if you want to add a certificate to another user. For
adding a certificate to your own profile, you do not need the administrator’s credentials.
4. In the Command-Line Interface, display the certificate in the PEM format using the cat utility
or a text editor:
5. Copy and paste the certificate from the CLI into the window that has opened in the Web UI.
6. Click Add.
Instead of uploading the whole certificate, it is also possible to upload certificate mapping data to a user
entry in IdM. User entries containing either full certificates or certificate mapping data can be used in
conjunction with corresponding certificate mapping rules to facilitate the configuration of smart card
11
Red Hat Enterprise Linux 8 Managing smart card authentication
authentication for system administrators. For details, see Certificate mapping rules for configuring
authentication on smart cards.
NOTE
If the user’s certificate has been issued by the IdM Certificate Authority, the certificate is
already stored in the user entry, and you can skip this section.
Prerequisites
You have the certificate that you want to add to the user entry at your disposal.
Procedure
1. Log into the IdM CLI as an administrator if you want to add a certificate to another user:
For adding a certificate to your own profile, you do not need the administrator’s credentials:
2. Create an environment variable containing the certificate with the header and footer removed
and concatenated into a single line, which is the format expected by the ipa user-add-cert
command:
Note that certificate in the testuser.crt file must be in the PEM format.
3. Add the certificate to the profile of sc_user using the ipa user-add-cert command:
You must:
Install the opensc package which provides a set of libraries and utilities to work with smart
cards.
Start the pcscd service which communicates with the smart card reader.
Procedure
12
CHAPTER 1. CONFIGURING IDENTITY MANAGEMENT FOR SMART CARD AUTHENTICATION
Storing the certificate, private key, and public key in the slot
Locking the smart card settings (some smart cards require this type of finalization)
Prerequisites
You have the private key, public key, and certificate to store on the smart card. In this
procedure, testuser.key, testuserpublic.key, and testuser.crt are the names used for the
private key, public key, and the certificate.
Your current smart card user PIN and Security Officer PIN (SO-PIN)
Procedure
1. Erase your smart card and authenticate yourself with your PIN:
2. Initialize your smart card, set your user PIN and PUK, and your Security Officer PIN and PUK:
13
Red Hat Enterprise Linux 8 Managing smart card authentication
The label is set to a human-readable value, in this case, testuser. The auth-id must be two
hexadecimal values, in this case it is set to 01.
4. Store and label the private key in the new slot on the smart card:
NOTE
The value you specify for --id must be the same when storing your private key,
and certificate. If you do not specify a value for --id, a more complicated value is
calculated by the tool and it is therefore easier to define your own value.
5. Store and label the certificate in the new slot on the smart card:
6. (Optional) Store and label the public key in the new slot on the smart card:
NOTE
If the public key corresponds to a private key and/or certificate, you should
specify the same ID as that private key and/or certificate.
7. (Optional) Some smart cards require you to finalize the card by locking the settings:
$ pkcs15-init -F
At this stage, your smart card includes the certificate, private key, and public key in the newly
created slot. You have also created your user PIN and PUK and the Security Officer PIN and
PUK.
Prerequisites
14
CHAPTER 1. CONFIGURING IDENTITY MANAGEMENT FOR SMART CARD AUTHENTICATION
Prerequisites
The IdM server has been configured for smart card authentication.
The certificate installed on your smart card is known to the IdM server.
Procedure
3. If the Password Required dialog box opens, add the PIN to unlock the smart card and click the
OK button.
The User Identification Request dialog box opens.
If the smart card contains more than one certificate, select the certificate you want to use for
authentication in the drop down list below Choose a certificate to present as identification.
15
Red Hat Enterprise Linux 8 Managing smart card authentication
The advantage of using smart card authentication is that if the user account is part of the Identity
Management domain, you also get a ticket-granting ticket (TGT).
Prerequisites
The certificate on the smart card maps to the user entry through:
Assigning the certificate to a particular user entry. For details, see, Adding a certificate to a
user entry in the IdM Web UI or Adding a certificate to a user entry in the IdM CLI .
The certificate mapping data being applied to the account. For details, see Certificate
mapping rules for configuring authentication on smart cards.
Procedure
You are successfully logged in to the RHEL system and you have a TGT provided by the IdM server.
Verification steps
$ klist
Ticket cache: KEYRING:persistent:1358900015:krb_cache_TObtNMd
Default principal: [email protected]
Prerequisites
16
CHAPTER 1. CONFIGURING IDENTITY MANAGEMENT FOR SMART CARD AUTHENTICATION
Prerequisites
Procedure
$ su - example.user
PIN for smart_card
If the configuration is successful, you are prompted to enter the smart card PIN.
17
Red Hat Enterprise Linux 8 Managing smart card authentication
Your deployment is based on cross-forest trust between Identity Management (IdM) and Active
Directory (AD).
You want to allow smart card authentication for users whose accounts are stored in AD.
Certificates are created and stored in Active Directory Certificate Services (ADCS).
Copying CA and user certificates from Active Directory to the IdM server and client
Configuring the IdM server and clients for smart card authentication using ADCS certificates
Converting a PFX (PKCS#12) file to be able to store the certificate and private key into the
smart card
Prerequisites
Active Directory Certificate Services (ADCS) is installed and certificates for users are generated
You can store user credentials on the smart card in the form of a private key and a certificate, and
special software and hardware is used to access them. You place the smart card into a reader or a USB
socket and supply the PIN code for the smart card instead of providing your password.
You can configure how you want smart card authentication to work in a particular IdM client:
Users can authenticate with the user name and password or with their smart cards
Users can authenticate with their smart cards, and passwords are not allowed
Users can use the smart card for logout with a function lock on removal, and passwords are not
allowed
User certificates issued by the IdM certificate authority. For details, see Configuring Identity
Management for smart card authentication.
18
CHAPTER 2. CONFIGURING CERTIFICATES ISSUED BY ADCS FOR SMART CARD AUTHENTICATION IN IDM
User certificates issued by the ADCS certificate authority. For details, see Configuring
certificates issued by ADCS for smart card authentication in IdM.
User certificates issued by local certification authority generated on a RHEL system. For details,
see Configuring and importing local certificates to a smart card .
NOTE
If you want to start to use smart card authentication, see the hardware requirements:
Smart Card support in RHEL8 .
[Optional] If you are using Certificate Authority Web Enrollment, the Internet Information
Services (IIS) must be configured
You will need a certificate in the following format: Personal Information Exchange — PKCS
#12(.PFX)
A user certificate with a private key in the PFX format: aduser1.pfx on an IdM client.
NOTE
This procedure expects SSH access is allowed. If SSH is unavailable the user must copy
the file from the AD Server to the IdM server and client.
Procedure
1. Connect from the IdM server and copy the adcs-winserver-ca.cer root certificate to the IdM
server:
19
Red Hat Enterprise Linux 8 Managing smart card authentication
[email protected]'s password:
Connected to [email protected].
sftp> cd <Path to certificates>
sftp> ls
adcs-winserver-ca.cer aduser1.pfx
sftp>
sftp> get adcs-winserver-ca.cer
Fetching <Path to certificates>/adcs-winserver-ca.cer to adcs-winserver-ca.cer
<Path to certificates>/adcs-winserver-ca.cer 100% 1254 15KB/s 00:00
sftp quit
2. Connect from the IdM client and copy the aduser1.pfx user certificate to the client:
Now the CA certificate is stored in the IdM server and the user certificates is stored on the client
machine.
2.4. CONFIGURING THE IDM SERVER AND CLIENTS FOR SMART CARD
AUTHENTICATION USING ADCS CERTIFICATES
You must configure the IdM (Identity Management) server and clients to be able to use smart card
authentication in the IdM environment. IdM includes the ipa-advise scripts which makes all necessary
changes:
On an IdM server: Preparing the ipa-advise script to configure your IdM server for smart card
authentication.
On an IdM server: Preparing the ipa-advise script to configure your IdM client for smart card
authentication.
On an IdM server: Applying the the ipa-advise server script on the IdM server using the AD
certificate.
On an IdM client: Applying the the ipa-advise client script on the IdM client using the AD
certificate.
20
CHAPTER 2. CONFIGURING CERTIFICATES ISSUED BY ADCS FOR SMART CARD AUTHENTICATION IN IDM
Prerequisites
Procedure
1. On the IdM server, use the ipa-advise script for configuring a client:
2. On the IdM server, use the ipa-advise script for configuring a server:
It enables Public Key Cryptography for Initial Authentication in Kerberos (PKINIT) on the
Key Distribution Center (KDC).
The CA certificate is installed in the correct format on the IdM server and client systems and next step is
to copy the user certificates onto the smart card itself.
21
Red Hat Enterprise Linux 8 Managing smart card authentication
extract the private key and the certificate to two different files
Prerequisites
Procedure
[root@idmclient1 ~]# openssl pkcs12 -in adduser1.pfx -nocerts -out adduser1.pem >
aduser1.key
At this point, you can store the aduser1.key and aduser1.crt into the smart card.
You must:
Install the opensc package which provides a set of libraries and utilities to work with smart
cards.
Start the pcscd service which communicates with the smart card reader.
Procedure
22
CHAPTER 2. CONFIGURING CERTIFICATES ISSUED BY ADCS FOR SMART CARD AUTHENTICATION IN IDM
Storing the certificate, private key, and public key in the slot
Locking the smart card settings (some smart cards require this type of finalization)
Prerequisites
You have the private key, public key, and certificate to store on the smart card. In this
procedure, testuser.key, testuserpublic.key, and testuser.crt are the names used for the
private key, public key, and the certificate.
Your current smart card user PIN and Security Officer PIN (SO-PIN)
Procedure
1. Erase your smart card and authenticate yourself with your PIN:
2. Initialize your smart card, set your user PIN and PUK, and your Security Officer PIN and PUK:
The label is set to a human-readable value, in this case, testuser. The auth-id must be two
hexadecimal values, in this case it is set to 01.
23
Red Hat Enterprise Linux 8 Managing smart card authentication
4. Store and label the private key in the new slot on the smart card:
NOTE
The value you specify for --id must be the same when storing your private key,
and certificate. If you do not specify a value for --id, a more complicated value is
calculated by the tool and it is therefore easier to define your own value.
5. Store and label the certificate in the new slot on the smart card:
6. (Optional) Store and label the public key in the new slot on the smart card:
NOTE
If the public key corresponds to a private key and/or certificate, you should
specify the same ID as that private key and/or certificate.
7. (Optional) Some smart cards require you to finalize the card by locking the settings:
$ pkcs15-init -F
At this stage, your smart card includes the certificate, private key, and public key in the newly
created slot. You have also created your user PIN and PUK and the Security Officer PIN and
PUK.
slow reader
slow response from the OCSP (Online Certificate Status Protocol) responder if OCSP is used to
verify the certificates
In this case you can prolong the following timeouts in the sssd.conf file, for example, to 60 seconds:
24
CHAPTER 2. CONFIGURING CERTIFICATES ISSUED BY ADCS FOR SMART CARD AUTHENTICATION IN IDM
p11_child_timeout
krb5_auth_timeout
Prerequisites
Procedure
[pam]
p11_child_timeout = 60
[domain/IDM.EXAMPLE.COM]
krb5_auth_timeout = 60
Now, the interaction with the smart card is allowed to run for 1 minute (60 seconds) before
authentication will fail with a timeout.
After creating such a rule, the user is able to authenticate with their smart card in both domains.
For details about certificate mapping rules, see Certificate mapping rules for configuring authentication
on smart cards.
25
Red Hat Enterprise Linux 8 Managing smart card authentication
Certificate mapping rules are also convenient if the IdM environment is large with a lot of users using
smart cards. In this situation, adding full certificates can be complicated. The subject and issuer are
predictable in most scenarios and thus easier to add ahead of time than the full certificate. As a system
administrator, you can create a certificate mapping rule and add certificate mapping data to a user entry
even before a certificate is issued to a particular user. Once the certificate is issued, the user can log in
using the certificate even though the full certificate has not yet been uploaded to the user entry.
In addition, as certificates have to be renewed at regular intervals, certificate mapping rules reduce
administrative overhead. When a user’s certificate gets renewed, the administrator does not have to
update the user entry. For example, if the mapping is based on the Subject and Issuer values, and if the
new certificate has the same subject and issuer as the old one, the mapping still applies. If, in contrast,
the full certificate was used, then the administrator would have to upload the new certificate to the user
entry to replace the old one.
1. An administrator has to load the certificate mapping data (typically the issuer and subject) or
the full certificate into a user account.
2. An administrator has to create a certificate mapping rule to allow successful logging into IdM for
a user
b. whose certificate mapping data entry matches the information on the certificate
For details on the individual components that make up a mapping rule and how to obtain and
use them, see Components of an identity mapping rule in IdM and Obtaining the issuer from a
certificate for use in a matching rule .
Afterwards, when the end-user presents the certificate, stored either in the filesystem or on a smart
card, authentication is successful.
Certificate mapping rules are a convenient way to enable access to IdM resources for users who have
smart card certificates that were issued by the trusted AD Certificate System. Depending on the AD
configuration, the following scenarios are possible:
If the certificate is issued by AD but the user and the certificate are stored in IdM, the mapping
and the whole processing of the authentication request takes place on the IdM side. For details
of configuring this scenario, see Configuring certificate mapping for users stored in IdM
26
CHAPTER 3. CERTIFICATE MAPPING RULES FOR CONFIGURING AUTHENTICATION ON SMART CARDS
If the user is stored in AD, the processing of the authentication request takes place in AD. There
are three different subcases:
The AD user entry contains the whole certificate. For details how to configure IdM in this
scenario, see Configuring certificate mapping for users whose AD user entry contains the
whole certificate.
AD is configured to map user certificates to user accounts. In this case, the AD user entry
does not contain the whole certificate but instead contains an attribute called
altSecurityIdentities. For details how to configure IdM in this scenario, see Configuring
certificate mapping if AD is configured to map user certificates to user accounts.
The AD user entry contains neither the whole certificate nor the mapping data. In this case,
the only solution is to use the ipa idoverrideuser-add command to add the whole
certificate to the AD user’s ID override in IdM. For details, see Configuring certificate
mapping if AD user entry contains no certificate or mapping data .
Mapping rule
The mapping rule component associates (or maps) a certificate with one or more user accounts. The
rule defines an LDAP search filter that associates a certificate with the intended user account.
Certificates issued by different certificate authorities (CAs) might have different properties and
might be used in different domains. Therefore, IdM does not apply mapping rules unconditionally, but
only to the appropriate certificates. The appropriate certificates are defined using matching rules.
Note that if you leave the mapping rule option empty, the certificates are searched in the
userCertificate attribute as a DER encoded binary file.
Define the mapping rule in the CLI using the --maprule option.
Matching rule
The matching rule component selects a certificate to which you want to apply the mapping rule. The
default matching rule matches certificates with the digitalSignature key usage and clientAuth
extended key usage.
Define the matching rule in the CLI using the --matchrule option.
Domain list
The domain list specifies the identity domains in which you want IdM to search the users when
processing identity mapping rules. If you leave the option unspecified, IdM searches the users only in
the local domain to which the IdM client belongs.
Define the domain in the CLI using the --domain option.
Priority
When multiple rules are applicable to a certificate, the rule with the highest priority takes precedence.
All other rules are ignored.
The lower the numerical value, the higher the priority of the identity mapping rule. For
example, a rule with a priority 1 has higher priority than a rule with a priority 2.
27
Red Hat Enterprise Linux 8 Managing smart card authentication
Define the mapping rule priority in the CLI using the --priority option.
Prerequisites
Procedure
1. Obtain the user information from the certificate. Use the openssl x509 certificate display and
signing utility with:
the -noout option to prevent the output of an encoded version of the request
the -in option to specify the input file name to read the certificate from
the -nameopt option with the RFC2253 value to display the output with the most specific
relative distinguished name (RDN) first
If the input file contains an Identity Management certificate, the output of the command
shows that the Issuer is defined using the Organisation information:
If the input file contains an Active Directory certificate, the output of the command shows
that the Issuer is defined using the Domain Component information:
2. Optionally, to create a new mapping rule in the CLI based on a matching rule which specifies that
the certificate issuer must be the extracted AD-WIN2012R2-CA of the ad.example.com
domain and the subject on the certificate must match the certmapdata entry in a user account
28
CHAPTER 3. CERTIFICATE MAPPING RULES FOR CONFIGURING AUTHENTICATION ON SMART CARDS
in IdM:
29
Red Hat Enterprise Linux 8 Managing smart card authentication
Obtain a user certificate for the user who wants to authenticate with a smart card. The
certificate should be generated by a trustworthy Certification Authority used in the domain.
If you cannot get the certificate, you can generate a user certificate signed by a local certificate
authority for testing purposes,
IMPORTANT
If a host can be part of the domain, add the host to the domain and use certificates
generated by Active Directory or Identity Management Certification Authority.
For details about how to create IdM certificates for a smart card, see Configuring Identity
Management for smart card authentication.
Prerequisites
Authselect installed
The authselect tool configures user authentication on Linux hosts and you can use it to
configure smart card authentication parameters. For details about authselect, see Explaining
authselect.
30
CHAPTER 4. CONFIGURING AND IMPORTING LOCAL CERTIFICATES TO A SMART CARD
WARNING
The following steps are intended for testing purpose only. Certificates generated by
a local self-signed Certificate Authority are not as secure as using AD, IdM, or RHCS
Certification Authority. You should use a certificate generated by your enterprise
Certification Authority even if the host is not part of the domain.
Procedure
1. Create a directory where you can generate the certificate, for example:
# mkdir /tmp/ca
# cd /tmp/ca
2. Set up the certificate (copy this text to your command line in the ca directory):
[ CA_default ]
dir =.
database = \$dir/index.txt
new_certs_dir = \$dir/newcerts
certificate = \$dir/rootCA.crt
serial = \$dir/serial
private_key = \$dir/rootCA.key
RANDFILE = \$dir/rand
default_days = 365
default_crl_days = 30
default_md = sha256
policy = policy_any
email_in_dn = no
name_opt = ca_default
cert_opt = ca_default
copy_extensions = copy
[ usr_cert ]
authorityKeyIdentifier = keyid, issuer
[ v3_ca ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer:always
basicConstraints = CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
[ policy_any ]
31
Red Hat Enterprise Linux 8 Managing smart card authentication
organizationName = supplied
organizationalUnitName = supplied
commonName = supplied
emailAddress = optional
[ req ]
distinguished_name = req_distinguished_name
prompt = no
[ req_distinguished_name ]
O = Example
OU = Example Test
CN = Example Test CA
EOF
This command writes a number 01 in the serial file. It is a serial number of the certificate. With
each new certificate released by this CA the number increases by one.
This key is generated in the local system which is not secure, therefore, remove the key from
the system when the key is stored in the card.
You can create a key directly in the smart card as well. For doing this, follow instructions created
by the manufacturer of your smart card.
9. Create the certificate signing request configuration file (copy this text to your command line in
the ca directory):
32
CHAPTER 4. CONFIGURING AND IMPORTING LOCAL CERTIFICATES TO A SMART CARD
[ req ]
distinguished_name = req_distinguished_name
prompt = no
[ req_distinguished_name ]
O = Example
OU = Example Test
CN = testuser
[ req_exts ]
basicConstraints = CA:FALSE
nsCertType = client, email
nsComment = "testuser"
subjectKeyIdentifier = hash
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth, emailProtection, msSmartcardLogin
subjectAltName = otherName:msUPN;UTF8:[email protected],
email:[email protected]
EOF
At this point, the certification authority and certificates are successfully generated and prepared for
import into a smart card.
Prerequisites
Procedure
# rpm -q sssd
sssd-2.0.0.43.el8_0.3.x86_64
33
Red Hat Enterprise Linux 8 Managing smart card authentication
# file /etc/sssd/pki
/etc/sssd/pki/: directory
# cp /tmp/ca/rootCA.crt /etc/sssd/pki/sssd_auth_ca_db.pem
Now you have successfully generated the certificate authority and certificates, and you have saved them
in the /etc/sssd/pki directory.
NOTE
If you want to share the Certificate Authority certificates with another application, you
can change a location in sssd.conf:
Red Hat recommends to keep the default path and use a dedicated Certificate Authority
certificate file for SSSD to make sure that only Certificate Authorities trusted for
authentication are listed here.
You must:
Install the opensc package which provides a set of libraries and utilities to work with smart
cards.
Start the pcscd service which communicates with the smart card reader.
Procedure
34
CHAPTER 4. CONFIGURING AND IMPORTING LOCAL CERTIFICATES TO A SMART CARD
This section describes smart card configuration with the pkcs15-init tool, which helps you to configure:
Storing the certificate, private key, and public key in the slot
Locking the smart card settings (some smart cards require this type of finalization)
Prerequisites
You have the private key, public key, and certificate to store on the smart card. In this
procedure, testuser.key, testuserpublic.key, and testuser.crt are the names used for the
private key, public key, and the certificate.
Your current smart card user PIN and Security Officer PIN (SO-PIN)
Procedure
1. Erase your smart card and authenticate yourself with your PIN:
2. Initialize your smart card, set your user PIN and PUK, and your Security Officer PIN and PUK:
The label is set to a human-readable value, in this case, testuser. The auth-id must be two
hexadecimal values, in this case it is set to 01.
4. Store and label the private key in the new slot on the smart card:
35
Red Hat Enterprise Linux 8 Managing smart card authentication
NOTE
The value you specify for --id must be the same when storing your private key,
and certificate. If you do not specify a value for --id, a more complicated value is
calculated by the tool and it is therefore easier to define your own value.
5. Store and label the certificate in the new slot on the smart card:
6. (Optional) Store and label the public key in the new slot on the smart card:
NOTE
If the public key corresponds to a private key and/or certificate, you should
specify the same ID as that private key and/or certificate.
7. (Optional) Some smart cards require you to finalize the card by locking the settings:
$ pkcs15-init -F
At this stage, your smart card includes the certificate, private key, and public key in the newly
created slot. You have also created your user PIN and PUK and the Security Officer PIN and
PUK.
the configuration necessary for enabling authentication using a certificate stored on a smart
card
The lock on removal configuration enforces log out after the smart card removal.
For details about configuring smart cards with authselect, see Configuring smart cards using authselect .
Prerequisites
36
CHAPTER 4. CONFIGURING AND IMPORTING LOCAL CERTIFICATES TO A SMART CARD
Your username matches the Common Name (CN) or User ID (UID) in the certificate’s
SUBJECT.
Procedure
1. Create a new directory for SSH keys in the home directory of the user who uses smart card
authentication:
# mkdir /home/example.user/.ssh
2. Run the ssh-keygen -D command with the opensc library to retrieve the existing public key
paired with the private key on the smart card, and add it to the authorized_keys list of the
user’s SSH keys directory to enable SSH access with smart card authentication.
3. SSH requires access right configuration for the /.ssh directory and the authorized_keys file. To
set or change the access rights, enter:
# cat ~example.user/.ssh/authorized_keys
5. Verify that the smart card authentication is enabled in the /etc/sssd/sssd.conf file:
In the [pam] section, enable the pam certificate authentication module: pam_cert_auth = True
If the sssd.conf file has not been created yet, you can create the minimal functional
configuration by copying the following script to the command line:
[nss]
[pam]
pam_cert_auth = True
37
Red Hat Enterprise Linux 8 Managing smart card authentication
[domain/shadowutils]
id_provider = files
EOF
6. To use the SSH keys, configure the authentication with the authselect command:
Now, you can verify the SSH access with the following command:
If the configuration is successful, you are prompted to enter the smart card PIN.
The configuration works now locally. Now you can copy the public key and distribute it to
authorized_keys files located on all servers on which you want to use SSH.
38
CHAPTER 5. CONFIGURING SMART CARDS USING AUTHSELECT
Prerequisites
Authselect installed
The authselect tool configures user authentication on Linux hosts and you can use it to
configure smart card authentication parameters. For details about authselect, see Configuring
user authentication using authselect.
Local Certification Authority. You can use a certificate generated by the Local Certification
Authority if the user is not part of a domain or for testing purposes.
For details about how to create and import local certificates into a smart card, Configuring and
importing local certificates to a smart card.
Prerequisites
The card is inserted into the reader and connected to the computer.
39
Red Hat Enterprise Linux 8 Managing smart card authentication
Procedure
Enter the following command to allow smart card and password authentication:
At this point, smart card authentication is enabled, however, password authentication will work if you
forget your smart card at home.
NOTE
Prerequisites
The card is inserted into the reader and connected to the computer.
Procedure
NOTE
Once you run this command, password authentication will no longer work and you can
only log in with a smart card. Ensure smart card authentication is working before running
this command or you may be locked out of your system.
40
CHAPTER 5. CONFIGURING SMART CARDS USING AUTHSELECT
Prerequisites
The card is inserted into the reader and connected to the computer.
Procedure
Enter the following command to enable smart card authentication, disable password
authentication, and enforce lock on removal:
Now, when you remove the card, the screen locks. You must re-insert your smart card to unlock it.
41
Red Hat Enterprise Linux 8 Managing smart card authentication
After logging in locally using a smart card, you can log in through SSH to the remote machine and run
the sudo command without being prompted for a password by using SSH forwarding of the smart card
authentication.
For the purposes of this example, a client is connecting to the IPA server through SSH and running the
sudo command on the IPA server with credentials stored on a smart card.
For the purposes of this example, the less and whoami commands are added as sudo commands to test
the procedure.
Prerequisites
The IdM user has been created. For the purpose of this example, the user is ipauser1.
You have the hostname of the system where you are running sudo remotely. For the purpose of
this example, the host is server.ipa.test.
Procedure
42
CHAPTER 6. AUTHENTICATING TO SUDO REMOTELY USING SMART CARDS
5. Add the host on which you are running sudo to the adminrule:
Additional resources
Procedure
#%PAM-1.0
auth sufficient pam_ssh_agent_auth.so
authorized_keys_command=/usr/bin/sss_ssh_authorizedkeys
auth include system-auth
account include system-auth
password include system-auth
session include system-auth
3. To enable the SSH agent forwarding to work when you run sudo commands, add the following to
the /etc/sudoers file:
This allows users who have their public keys from smart cards stored in IPA/SSSD to
authenticate to sudo without entering a password.
Additional resources
43
Red Hat Enterprise Linux 8 Managing smart card authentication
This procedure describes how to configure the SSH agent and client in order to connect to sudo
remotely using a smart card.
Prerequisites
You have installed and set up the pam_ssh_agent_auth PAM module for sudo authentication
on the remote system where you are going to run sudo.
Procedure
eval `ssh-agent`
2. Add your smart card to the SSH agent. Enter your PIN when prompted:
ssh-add -s /usr/lib64/opensc-pkcs11.so
3. Connect via SSH with ssh-agent forwarding enabled (using the -A option) to the system where
you are going to run sudo remotely:
ssh -A [email protected]
Verification steps
sudo /usr/bin/whoami
44
CHAPTER 7. TROUBLESHOOTING AUTHENTICATION WITH SMART CARDS
Verifying that IdM Kerberos KDC can use PKINIT and that the CA certificates are correctly
located
Prerequisites
You have installed and configured your IdM Server and client for use with smart cards.
You have installed the certutil tool from the nss-tools package.
Procedure
1. Using the lsusb command, verify that the smart card reader is visible to the operating system:
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 072f:b100 Advanced Card Systems, Ltd ACR39U
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
For more information on the smart cards and readers tested and supported in RHEL, see Smart
Card support in RHEL8.
2. Ensure that the pcscd service and socket are enabled and running:
45
Red Hat Enterprise Linux 8 Managing smart card authentication
3. Using the p11-kit list-modules command, display information about the configured smart card
and the tokens present on the smart card:
$ p11-kit list-modules
p11-kit-trust: p11-kit-trust.so
[...]
opensc: opensc-pkcs11.so
library-description: OpenSC smartcard framework
library-manufacturer: OpenSC Project
library-version: 0.20
token: MyEID (sctest)
manufacturer: Aventra Ltd.
model: PKCS#15
serial-number: 8185043840990797
firmware-version: 40.1
flags:
rng
login-required
user-pin-initialized
token-initialized
46
CHAPTER 7. TROUBLESHOOTING AUTHENTICATION WITH SMART CARDS
5. Display the contents of the certificate on your smart card using the certutil command:
a. Run the following command to determine the correct name of your certificate:
NOTE
Ensure the name of the certificate is an exact match for the output displayed
in the previous step, in this example MyEID (sctest):Certificate.
47
Red Hat Enterprise Linux 8 Managing smart card authentication
Data Encipherment
6A:F9:64:F7:F2:A2:B5:04:88:27:6E:B8:53:3E:44:3E:F5:75:85:91:34:ED:48:A8:0D:F0:31:5
D:7B:C9:E0:EC
Fingerprint (SHA1):
B4:9A:59:9F:1C:A8:5D:0E:C1:A2:41:EC:FD:43:E0:80:5F:63:DF:29
Additional resources
Prerequisites
You have installed and configured your IdM Server and client for use with smart cards.
You are able to detect your smart card reader and display the contents of your smart card. See
Testing smart card access on the system .
Procedure
48
CHAPTER 7. TROUBLESHOOTING AUTHENTICATION WITH SMART CARDS
1. Verify you can authenticate with your smart card using su:
If you are not prompted for the smart card PIN, and either a password prompt or an
authorization error are returned, check the SSSD logs. See Troubleshooting authentication with
SSSD in IdM for information on logging in SSSD. The following is an example of an
authentication failure:
If the SSSD logs indicate an issue from the krb5_child, similar to the following, you may have an
issue with your CA certificates. To troubleshoot issues with certificates, see Verifying that IdM
Kerberos KDC can use Pkinit and that the CA certificates are correctly located.
[Pre-authentication failed: Failed to verify own certificate (depth 0): unable to get local issuer
certificate: could not load the shared library]
If the SSSD logs indicate a timeout either from p11_child or krb5_child, you may need to
increase the SSSD timeouts and try authenticating again with your smart card. See Increasing
SSSD timeouts for details on how to increase the timeouts.
2. Verify your GDM smart card authentication configuration is correct. A success message for
PAM authentication should be returned as shown below:
testing pam_authenticate
49
Red Hat Enterprise Linux 8 Managing smart card authentication
PAM Environment:
- PKCS11_LOGIN_TOKEN_NAME=MyEID (sctest)
- KRB5CCNAME=KCM:
If an authentication error, similar to the following, is returned, check the SSSD logs to try and
determine what is causing the issue. See Troubleshooting authentication with SSSD in IdM for
information on logging in SSSD.
PAM Environment:
- no env -
If PAM authentication continues to fail, clear your cache and run the command again.
# sssctl cache-remove
SSSD must not be running. Stop SSSD now? (yes/no) [yes] yes
Creating backup of local data…
Removing cache files…
SSSD needs to be running. Start SSSD now? (yes/no) [yes] yes
7.3. VERIFYING THAT IDM KERBEROS KDC CAN USE PKINIT AND THAT
THE CA CERTIFICATES ARE CORRECTLY LOCATED
This procedure describes how to verify that IdM Kerberos KDC can use PKINIT and also describes how to
verify your CA certificates are correctly located.
Prerequisites
You have installed and configured your IdM Server and client for use with smart cards.
You are able to detect your smart card reader and display the contents of your smart card. See
Testing smart card access on the system .
Procedure
1. Run the kinit utility to authenticate as the idmuser1 with the certificate stored on your smart
card:
2. Enter your smart card PIN. If you are not prompted for your PIN, check that you can detect your
smart card reader and display the contents of your smart card. See Testing smart card
authentication.
3. If your PIN is accepted and you are then prompted for your password, you might be missing your
CA signing certificate.
a. Verify the CA chain is listed in the default certificate bundle file using openssl commands:
50
CHAPTER 7. TROUBLESHOOTING AUTHENTICATION WITH SMART CARDS
ii. Read the user certificate information from the smart card in DER format:
$ openssl x509 -in cert.der -inform DER -out cert.pem -outform PEM
iv. Verify the certificate has valid issuer signatures up to the CA:
4. If your smart card contains several certificates, kinit might fail to choose the correct certificate
for authentication. In this case, you need to specify the certificate ID as an argument to the kinit
command using the certid=<ID> option.
a. Check how many certificates are stored on the smart card and get the certificate ID for the
one you are using:
51
Red Hat Enterprise Linux 8 Managing smart card authentication
$ klist
Ticket cache: KCM:0:11485
Default principal: [email protected]
$ kdestroy -A
Additional resources
If there is a timeout entry in the log file, try increasing the SSSD timeouts as outlined in this procedure.
Prerequisites
You have configured your IdM Server and client for smart card authentication.
Procedure
# vim /etc/sssd/sssd.conf
2. In your domain section, for example [domain/idm.example.com], add the following option:
krb5_auth_timeout = 60
p11_child_timeout = 60
# sssctl cache-remove
SSSD must not be running. Stop SSSD now? (yes/no) [yes] yes
Creating backup of local data…
Removing cache files…
SSSD needs to be running. Start SSSD now? (yes/no) [yes] yes
52
CHAPTER 7. TROUBLESHOOTING AUTHENTICATION WITH SMART CARDS
Once you have increased the timeouts, try authenticating again using your smart card. See Testing
smart card authentication for more details.
53