Este conteúdo não está disponível no idioma selecionado.
Chapter 8. Granting sudo access to an IdM user on an IdM client
Learn more about granting sudo access to users in Identity Management.
8.1. Sudo access on an IdM client Copiar o linkLink copiado para a área de transferência!
System administrators can grant sudo access to allow non-root users to execute administrative commands that are normally reserved for the root user. Consequently, when users need to perform an administrative command normally reserved for the root user, they precede that command with sudo. After entering their password, the command is executed as if they were the root user. To execute a sudo command as another user or group, such as a database service account, you can configure a RunAs alias for a sudo rule.
If a Red Hat Enterprise Linux (RHEL) 8 host is enrolled as an Identity Management (IdM) client, you can specify sudo rules defining which IdM users can perform which commands on the host in the following ways:
-
Locally in the
/etc/sudoersfile - Centrally in IdM
You can create a central sudo rule for an IdM client using the command line (CLI) and the IdM Web UI.
You can also configure password-less authentication for sudo using the Generic Security Service Application Programming Interface (GSSAPI), the native way for UNIX-based operating systems to access and authenticate Kerberos services. You can use the pam_sss_gss.so Pluggable Authentication Module (PAM) to invoke GSSAPI authentication via the SSSD service, allowing users to authenticate to the sudo command with a valid Kerberos ticket.
8.2. Granting sudo access to an IdM user on an IdM client using the CLI Copiar o linkLink copiado para a área de transferência!
In Identity Management (IdM), you can grant sudo access for a specific command to an IdM user account on a specific IdM host. First, add a sudo command and then create a sudo rule for one or more commands.
For example, complete this procedure to create the idm_user_reboot sudo rule to grant the idm_user account the permission to run the /usr/sbin/reboot command on the idmclient machine.
Prerequisites
- You are logged in as IdM administrator.
- You have created a user account for idm_user in IdM and unlocked the account by creating a password for the user. For details on adding a new IdM user using the CLI, see Adding users using the command line.
-
No local idm_user account is present on the idmclient host. The idm_user user is not listed in the local
/etc/passwdfile.
Procedure
Retrieve a Kerberos ticket as the IdM
admin.kinit admin
[root@idmclient ~]# kinit adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
/usr/sbin/rebootcommand to the IdM database ofsudocommands:ipa sudocmd-add /usr/sbin/reboot
[root@idmclient ~]# ipa sudocmd-add /usr/sbin/reboot ------------------------------------- Added Sudo Command "/usr/sbin/reboot" ------------------------------------- Sudo Command: /usr/sbin/rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
sudorule named idm_user_reboot:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
/usr/sbin/rebootcommand to the idm_user_reboot rule:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the idm_user_reboot rule to the IdM idmclient host:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the idm_user account to the idm_user_reboot rule:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Define the validity of the idm_user_reboot rule:
To define the time at which a
sudorule starts to be valid, use theipa sudorule-mod sudo_rule_namecommand with the--setattr sudonotbefore=DATEoption. The DATE value must follow the yyyymmddHHMMSSZ format, with seconds specified explicitly. For example, to set the start of the validity of the idm_user_reboot rule to 31 December 2025 12:34:00, enter:ipa sudorule-mod idm_user_reboot --setattr sudonotbefore=20251231123400Z
[root@idmclient ~]# ipa sudorule-mod idm_user_reboot --setattr sudonotbefore=20251231123400ZCopy to Clipboard Copied! Toggle word wrap Toggle overflow To define the time at which a sudo rule stops being valid, use the
--setattr sudonotafter=DATEoption. For example, to set the end of the idm_user_reboot rule validity to 31 December 2026 12:34:00, enter:ipa sudorule-mod idm_user_reboot --setattr sudonotafter=20261231123400Z
[root@idmclient ~]# ipa sudorule-mod idm_user_reboot --setattr sudonotafter=20261231123400ZCopy to Clipboard Copied! Toggle word wrap Toggle overflow
NotePropagating the changes from the server to the client can take a few minutes.
Verification
- Log in to the idmclient host as the idm_user account.
Display which
sudorules the idm_user account is allowed to perform.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the machine using
sudo. Enter the password for idm_user when prompted:sudo /usr/sbin/reboot
[idm_user@idmclient ~]$ sudo /usr/sbin/reboot [sudo] password for idm_user:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.3. Granting sudo access to an AD user on an IdM client using the CLI Copiar o linkLink copiado para a área de transferência!
Identity Management (IdM) system administrators can use IdM user groups to set access permissions, host-based access control, sudo rules, and other controls on IdM users. IdM user groups grant and restrict access to IdM domain resources.
You can add both Active Directory (AD) users and AD groups to IdM user groups. To do that:
- Add the AD users or groups to a non-POSIX external IdM group.
- Add the non-POSIX external IdM group to an IdM POSIX group.
You can then manage the privileges of the AD users by managing the privileges of the POSIX group. For example, you can grant sudo access for a specific command to an IdM POSIX user group on a specific IdM host.
It is also possible to add AD user groups as members to IdM external groups. This might make it easier to define policies for Windows users, by keeping the user and group management within the single AD realm.
Do not use ID overrides of AD users for SUDO rules in IdM. ID overrides of AD users represent only POSIX attributes of AD users, not AD users themselves.
You can add ID overrides as group members. However, you can only use this functionality to manage IdM resources in the IdM API. The possibility to add ID overrides as group members is not extended to POSIX environments and you therefore cannot use it for membership in sudo or host-based access control (HBAC) rules.
Follow this procedure to create the ad_users_reboot sudo rule to grant the administrator@ad-domain.com AD user the permission to run the /usr/sbin/reboot command on the idmclient IdM host, which is normally reserved for the root user. administrator@ad-domain.com is a member of the ad_users_external non-POSIX group, which is, in turn, a member of the ad_users POSIX group.
Prerequisites
-
You have obtained the IdM
adminKerberos ticket-granting ticket (TGT). - A cross-forest trust exists between the IdM domain and the ad-domain.com AD domain.
-
No local administrator account is present on the idmclient host: the administrator user is not listed in the local
/etc/passwdfile.
Procedure
Create the ad_users group that contains the ad_users_external group with the administrator@ad-domain member:
- Optional: Create or select a corresponding group in the AD domain to use to manage AD users in the IdM realm. You can use multiple AD groups and add them to different groups on the IdM side.
Create the ad_users_external group and indicate that it contains members from outside the IdM domain by adding the
--externaloption:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteEnsure that the external group that you specify here is an AD security group with a
globaloruniversalgroup scope as defined in the Active Directory security groups document. For example, the Domain users or Domain admins AD security groups cannot be used because their group scope isdomain local.Create the ad_users group:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the administrator@ad-domain.com AD user to ad_users_external as an external member:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The AD user must be identified by a fully-qualified name, such as
DOMAIN\user_nameoruser_name@DOMAIN. The AD identity is then mapped to the AD SID for the user. The same applies to adding AD groups.- Add ad_users_external to ad_users as a member:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Grant the members of ad_users the permission to run
/usr/sbin/rebooton the idmclient host:Add the
/usr/sbin/rebootcommand to the IdM database ofsudocommands:ipa sudocmd-add /usr/sbin/reboot
[root@idmclient ~]# ipa sudocmd-add /usr/sbin/reboot ------------------------------------- Added Sudo Command "/usr/sbin/reboot" ------------------------------------- Sudo Command: /usr/sbin/rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
sudorule named ad_users_reboot:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
/usr/sbin/rebootcommand to the ad_users_reboot rule:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the ad_users_reboot rule to the IdM idmclient host:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
ad_usersgroup to the ad_users_reboot rule:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
NotePropagating the changes from the server to the client can take a few minutes.
Verification
Log in to the idmclient host as administrator@ad-domain.com, an indirect member of the
ad_usersgroup:ssh administrator@ad-domain.com@ipaclient
$ ssh administrator@ad-domain.com@ipaclient Password:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Display the
sudocommands thatadministrator@ad-domain.comis allowed to execute:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the machine using
sudo. Enter the password foradministrator@ad-domain.comwhen prompted:[administrator@ad-domain.com@idmclient ~]$ sudo /usr/sbin/reboot [sudo] password for administrator@ad-domain.com:
[administrator@ad-domain.com@idmclient ~]$ sudo /usr/sbin/reboot [sudo] password for administrator@ad-domain.com:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.4. Granting sudo access to an IdM user on an IdM client using the IdM Web UI Copiar o linkLink copiado para a área de transferência!
In Identity Management (IdM), you can grant sudo access for a specific command to an IdM user account on a specific IdM host. First, add a sudo command and then create a sudo rule for one or more commands.
Complete this procedure to create the idm_user_reboot sudo rule to grant the idm_user account the permission to run the /usr/sbin/reboot command on the idmclient machine.
Prerequisites
- You are logged in as IdM administrator.
-
You have created a user account for
idm_userin IdM and unlocked the account by creating a password for the user. For details on adding a new IdM user using the command line, see Adding users using the command line. -
No local
idm_useraccount is present on theidmclienthost. Theidm_useruser is not listed in the local/etc/passwdfile.
Procedure
Add the
/usr/sbin/rebootcommand to the IdM database ofsudocommands:-
Navigate to Policy
Sudo Sudo Commands. - Click Add in the upper right corner to open the Add sudo command dialog box.
Enter the command you want the user to be able to perform using
sudo:/usr/sbin/reboot.- Click Add.
-
Navigate to Policy
Use the new
sudocommand entry to create a sudo rule to allow idm_user to reboot the idmclient machine:-
Navigate to Policy
Sudo Sudo rules. - Click Add in the upper right corner to open the Add sudo rule dialog box.
-
Enter the name of the
sudorule: idm_user_reboot. - Click Add and Edit.
Specify the user:
- In the Who section, check the Specified Users and Groups radio button.
- In the User category the rule applies to subsection, click Add to open the Add users into sudo rule "idm_user_reboot" dialog box.
- In the Add users into sudo rule "idm_user_reboot" dialog box in the Available column, check the idm_user checkbox, and move it to the Prospective column.
- Click Add.
Specify the host:
- In the Access this host section, check the Specified Hosts and Groups radio button.
- In the Host category this rule applies to subsection, click Add to open the Add hosts into sudo rule "idm_user_reboot" dialog box.
- In the Add hosts into sudo rule "idm_user_reboot" dialog box in the Available column, check the idmclient.idm.example.com checkbox, and move it to the Prospective column.
- Click Add.
Specify the commands:
- In the Command category the rule applies to subsection of the Run Commands section, check the Specified Commands and Groups radio button.
- In the Sudo Allow Commands subsection, click Add to open the Add allow sudo commands into sudo rule "idm_user_reboot" dialog box.
-
In the Add allow sudo commands into sudo rule "idm_user_reboot" dialog box in the Available column, check the
/usr/sbin/rebootcheckbox, and move it to the Prospective column. - Click Add to return to the idm_sudo_reboot page.
Figure 8.1. Adding IdM sudo rule
Click Save in the top left corner.
The new rule is enabled by default.
NotePropagating the changes from the server to the client can take a few minutes.
-
Navigate to Policy
Verification
-
Log in to
idmclientasidm_user. Reboot the machine using
sudo. Enter the password foridm_userwhen prompted:sudo /usr/sbin/reboot
$ sudo /usr/sbin/reboot [sudo] password for idm_user:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If the sudo rule is configured correctly, the machine reboots.
8.5. Creating a sudo rule on the CLI that runs a command as a service account on an IdM client Copiar o linkLink copiado para a área de transferência!
In IdM, you can configure a sudo rule with a RunAs alias to run a sudo command as another user or group. For example, you might have an IdM client that hosts a database application, and you need to run commands as the local service account that corresponds to that application.
Use this example to create a sudo rule on the command line called run_third-party-app_report to allow the idm_user account to run the /opt/third-party-app/bin/report command as the thirdpartyapp service account on the idmclient host.
Prerequisites
- You are logged in as IdM administrator.
-
You have created a user account for
idm_userin IdM and unlocked the account by creating a password for the user. For details on adding a new IdM user using the CLI, see Adding users using the command line. -
No local
idm_useraccount is present on theidmclienthost. Theidm_useruser is not listed in the local/etc/passwdfile. -
You have a custom application named
third-party-appinstalled on theidmclienthost. -
The
reportcommand for thethird-party-appapplication is installed in the/opt/third-party-app/bin/reportdirectory. -
You have created a local service account named
thirdpartyappto execute commands for thethird-party-appapplication.
Procedure
Retrieve a Kerberos ticket as the IdM
admin.kinit admin
[root@idmclient ~]# kinit adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
/opt/third-party-app/bin/reportcommand to the IdM database ofsudocommands:ipa sudocmd-add /opt/third-party-app/bin/report
[root@idmclient ~]# ipa sudocmd-add /opt/third-party-app/bin/report ---------------------------------------------------- Added Sudo Command "/opt/third-party-app/bin/report" ---------------------------------------------------- Sudo Command: /opt/third-party-app/bin/reportCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
sudorule namedrun_third-party-app_report:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
--users=<user>option to specify the RunAs user for thesudorule-add-runasusercommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The user (or group specified with the
--groups=*option) can be external to IdM, such as a local service account or an Active Directory user. Do not add a%prefix for group names.Add the
/opt/third-party-app/bin/reportcommand to therun_third-party-app_reportrule:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
run_third-party-app_reportrule to the IdMidmclienthost:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
idm_useraccount to therun_third-party-app_reportrule:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NotePropagating the changes from the server to the client can take a few minutes.
Verification
-
Log in to the
idmclienthost as theidm_useraccount. Test the new sudo rule:
Display which
sudorules theidm_useraccount is allowed to perform.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
reportcommand as thethirdpartyappservice account.sudo -u thirdpartyapp /opt/third-party-app/bin/report
[idm_user@idmclient ~]$ sudo -u thirdpartyapp /opt/third-party-app/bin/report [sudo] password for idm_user@idm.example.com: Executing report... Report successful.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.6. Creating a sudo rule in the IdM WebUI that runs a command as a service account on an IdM client Copiar o linkLink copiado para a área de transferência!
In IdM, you can configure a sudo rule with a RunAs alias to run a sudo command as another user or group. For example, you might have an IdM client that hosts a database application, and you need to run commands as the local service account that corresponds to that application.
Use this example to create a sudo rule in the IdM WebUI called run_third-party-app_report to allow the idm_user account to run the /opt/third-party-app/bin/report command as the thirdpartyapp service account on the idmclient host.
Prerequisites
- You are logged in as IdM administrator.
-
You have created a user account for
idm_userin IdM and unlocked the account by creating a password for the user. For details on adding a new IdM user using the CLI, see Adding users using the command line. -
No local
idm_useraccount is present on theidmclienthost. Theidm_useruser is not listed in the local/etc/passwdfile. -
You have a custom application named
third-party-appinstalled on theidmclienthost. -
The
reportcommand for thethird-party-appapplication is installed in the/opt/third-party-app/bin/reportdirectory. -
You have created a local service account named
thirdpartyappto execute commands for thethird-party-appapplication.
Procedure
Add the
/opt/third-party-app/bin/reportcommand to the IdM database ofsudocommands:-
Navigate to Policy
Sudo Sudo Commands. - Click Add in the upper right corner to open the Add sudo command dialog box.
Enter the command:
/opt/third-party-app/bin/report.- Click Add.
-
Navigate to Policy
Use the new
sudocommand entry to create the newsudorule:-
Navigate to Policy
Sudo Sudo rules. - Click Add in the upper right corner to open the Add sudo rule dialog box.
Enter the name of the
sudorule: run_third-party-app_report.- Click Add and Edit.
Specify the user:
- In the Who section, check the Specified Users and Groups radio button.
- In the User category the rule applies to subsection, click Add to open the Add users into sudo rule "run_third-party-app_report" dialog box.
In the Add users into sudo rule "run_third-party-app_report" dialog box in the Available column, check the idm_user checkbox, and move it to the Prospective column.
- Click Add.
Specify the host:
- In the Access this host section, check the Specified Hosts and Groups radio button.
- In the Host category this rule applies to subsection, click Add to open the Add hosts into sudo rule "run_third-party-app_report" dialog box.
In the Add hosts into sudo rule "run_third-party-app_report" dialog box in the Available column, check the idmclient.idm.example.com checkbox, and move it to the Prospective column.
- Click Add.
Specify the commands:
- In the Command category the rule applies to subsection of the Run Commands section, check the Specified Commands and Groups radio button.
- In the Sudo Allow Commands subsection, click Add to open the Add allow sudo commands into sudo rule "run_third-party-app_report" dialog box.
In the Add allow sudo commands into sudo rule "run_third-party-app_report" dialog box in the Available column, check the
/opt/third-party-app/bin/reportcheckbox, and move it to the Prospective column.- Click Add to return to the run_third-party-app_report page.
Specify the RunAs user:
- In the As Whom section, check the Specified Users and Groups radio button.
- In the RunAs Users subsection, click Add to open the Add RunAs users into sudo rule "run_third-party-app_report" dialog box.
In the Add RunAs users into sudo rule "run_third-party-app_report" dialog box, enter the
thirdpartyappservice account in the External box and move it to the Prospective column.- Click Add to return to the run_third-party-app_report page.
Click Save in the top left corner.
The new rule is enabled by default.
The following image shows the details of a sudo rule created in the IdM Web UI:
NotePropagating the changes from the server to the client can take a few minutes.
-
Navigate to Policy
Verification
-
Log in to the
idmclienthost as theidm_useraccount. Test the new sudo rule:
Display which
sudorules theidm_useraccount is allowed to perform.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
reportcommand as thethirdpartyappservice account.sudo -u thirdpartyapp /opt/third-party-app/bin/report
[idm_user@idmclient ~]$ sudo -u thirdpartyapp /opt/third-party-app/bin/report [sudo] password for idm_user@idm.example.com: Executing report... Report successful.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.7. Enabling GSSAPI authentication for sudo on an IdM client Copiar o linkLink copiado para a área de transferência!
Enable Generic Security Service Application Program Interface (GSSAPI) authentication on an IdM client for the sudo and sudo -i commands via the pam_sss_gss.so PAM module. With this configuration, IdM users can authenticate to the sudo command with their Kerberos ticket.
Prerequisites
-
You have created a
sudorule for an IdM user that applies to an IdM host. For this example, you have created theidm_user_rebootsudorule to grant theidm_useraccount the permission to run the/usr/sbin/rebootcommand on theidmclienthost. -
You need
rootprivileges to modify the/etc/sssd/sssd.conffile and PAM files in the/etc/pam.d/directory.
Procedure
-
Open the
/etc/sssd/sssd.confconfiguration file. Add the following entry to the
[domain/<domain_name>]section.[domain/<domain_name>] pam_gssapi_services = sudo, sudo-i
[domain/<domain_name>] pam_gssapi_services = sudo, sudo-iCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Save and close the
/etc/sssd/sssd.conffile. Restart the SSSD service to load the configuration changes.
systemctl restart sssd
[root@idmclient ~]# systemctl restart sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Determine if you have selected the
sssdauthselectprofile:authselect current
# authselect current Profile ID: sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the
sssdauthselectprofile is selected, enable GSSAPI authentication:authselect enable-feature with-gssapi
# authselect enable-feature with-gssapiCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the
sssdauthselectprofile is not selected, select it and enable GSSAPI authentication:authselect select sssd with-gssapi
# authselect select sssd with-gssapiCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into the host as the
idm_useraccount.ssh -l idm_user@idm.example.com localhost
[root@idm-client ~]# ssh -l idm_user@idm.example.com localhost idm_user@idm.example.com's password:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that you have a ticket-granting ticket as the
idm_useraccount.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: If you do not have Kerberos credentials for the
idm_useraccount, delete your current Kerberos credentials and request the correct ones.kdestroy -A kinit idm_user@IDM.EXAMPLE.COM
[idm_user@idmclient ~]$ kdestroy -A [idm_user@idmclient ~]$ kinit idm_user@IDM.EXAMPLE.COM Password for idm_user@idm.example.com:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the machine using
sudo, without specifying a password.sudo /usr/sbin/reboot
[idm_user@idmclient ~]$ sudo /usr/sbin/rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
8.8. Enabling GSSAPI authentication and enforcing Kerberos authentication indicators for sudo on an IdM client Copiar o linkLink copiado para a área de transferência!
You can enable Generic Security Service Application Program Interface (GSSAPI) authentication on an Identity Management (IdM) client for PAM-enabled services such as sudo and sudo -i via the pam_sss_gss.so PAM module. Additionally, you can enable only users who have logged in with a smart card to authenticate to those services with their Kerberos ticket.
You can use this procedure as a template to configure GSSAPI authentication with SSSD for other PAM-aware services, and further restrict access to only those users that have a specific authentication indicator attached to their Kerberos ticket.
However, using authentication indicators to restrict access has currently two limitations:
- Only deployments based on MIT Kerberos support authentication indicators. These deployments include, for example, RHEL IdM, FreeIPA in Fedora, and Samba AD DC in Fedora.
- Authentication indicators are removed from Kerberos tickets at the realm boundary.
Therefore, if you, for example, want to restrict sudo access by using pam_gssapi_indicators_map = sudo:pkinit, you can only apply this restriction to users stored in IdM LDAP. Tickets issued to users stored elsewhere, such as those stored in Active Directory, currently cannot satisfy the pam_gssapi_indicators_map = sudo:pkinit condition.
Prerequisites
-
You have created a
sudorule for an IdM user that applies to an IdM host. For this example, you have created theidm_user_rebootsudorule to grant theidm_useraccount the permission to run the/usr/sbin/rebootcommand on theidmclienthost. -
You have configured smart card authentication for the
idmclienthost. -
You need
rootprivileges to modify the/etc/sssd/sssd.conffile and PAM files in the/etc/pam.d/directory.
Procedure
-
Open the
/etc/sssd/sssd.confconfiguration file. Add the following entries to the
[domain/<domain_name>]section.[domain/<domain_name>] pam_gssapi_services = sudo, sudo-i pam_gssapi_indicators_map = sudo:pkinit, sudo-i:pkinit
[domain/<domain_name>] pam_gssapi_services = sudo, sudo-i pam_gssapi_indicators_map = sudo:pkinit, sudo-i:pkinitCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Save and close the
/etc/sssd/sssd.conffile. Restart the SSSD service to load the configuration changes.
systemctl restart sssd
[root@idmclient ~]# systemctl restart sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Determine if you have selected the
sssdauthselectprofile:authselect current
# authselect current Profile ID: sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Select the
sssdauthselectprofile:authselect select sssd
# authselect select sssdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable GSSAPI authentication:
authselect enable-feature with-gssapi
# authselect enable-feature with-gssapiCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the system to authenticate only users with smart cards:
authselect with-smartcard-required
# authselect with-smartcard-requiredCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into the host as the
idm_useraccount and authenticate with a smart card.ssh -l idm_user@idm.example.com localhost
[root@idmclient ~]# ssh -l idm_user@idm.example.com localhost PIN for smart_cardCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that you have a ticket-granting ticket as the smart card user.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display which
sudorules theidm_useraccount is allowed to perform.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the machine using
sudo, without specifying a password.sudo /usr/sbin/reboot
[idm_user@idmclient ~]$ sudo /usr/sbin/rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
8.9. SSSD options controlling GSSAPI authentication for PAM services Copiar o linkLink copiado para a área de transferência!
You can use the following options for the /etc/sssd/sssd.conf configuration file to adjust the GSSAPI configuration within the SSSD service.
- pam_gssapi_services
-
GSSAPI authentication with SSSD is disabled by default. You can use this option to specify a comma-separated list of PAM services that are allowed to try GSSAPI authentication using the
pam_sss_gss.soPAM module. To explicitly disable GSSAPI authentication, set this option to-. - pam_gssapi_indicators_map
This option only applies to Identity Management (IdM) domains. Use this option to list Kerberos authentication indicators that are required to grant PAM access to a service. Pairs must be in the format
<PAM_service>:_<required_authentication_indicator>_.Valid authentication indicators are:
-
otpfor two-factor authentication -
radiusfor RADIUS authentication -
pkinitfor PKINIT, smart card, or certificate authentication -
hardenedfor hardened passwords
-
- pam_gssapi_check_upn
-
This option is enabled and set to
trueby default. If this option is enabled, the SSSD service requires that the user name matches the Kerberos credentials. Iffalse, thepam_sss_gss.soPAM module authenticates every user that is able to obtain the required service ticket.
8.9.1. SSSD GSSAPI configuration examples Copiar o linkLink copiado para a área de transferência!
The following options enable Kerberos authentication for the sudo and sudo-i services, requires that sudo users authenticated with a one-time password, and user names must match the Kerberos principal. Because these settings are in the [pam] section, they apply to all domains:
[pam] pam_gssapi_services = sudo, sudo-i pam_gssapi_indicators_map = sudo:otp pam_gssapi_check_upn = true
[pam]
pam_gssapi_services = sudo, sudo-i
pam_gssapi_indicators_map = sudo:otp
pam_gssapi_check_upn = true
You can also set these options in individual [domain] sections to overwrite any global values in the [pam] section. The following options apply different GSSAPI settings to each domain:
- For the
idm.example.comdomain -
Enable GSSAPI authentication for the
sudoandsudo -iservices. -
Require certificate or smart card authentication authenticators for the
sudocommand. -
Require one-time password authentication authenticators for the
sudo -icommand. - Enforce matching user names and Kerberos principals.
-
Enable GSSAPI authentication for the
- For the
ad.example.comdomain -
Enable GSSAPI authentication only for the
sudoservice. - Do not enforce matching user names and principals.
-
Enable GSSAPI authentication only for the
8.10. Troubleshooting GSSAPI authentication for sudo Copiar o linkLink copiado para a área de transferência!
If you are unable to authenticate to the sudo service with a Kerberos ticket from IdM, use the following scenarios to troubleshoot your configuration.
Prerequisites
-
You have enabled GSSAPI authentication for the
sudoservice. See Enabling GSSAPI authentication for sudo on an IdM client. -
You need
rootprivileges to modify the/etc/sssd/sssd.conffile and PAM files in the/etc/pam.d/directory.
Procedure
If you see the following error, the Kerberos service might not able to resolve the correct realm for the service ticket based on the host name:
Server not found in Kerberos database
Server not found in Kerberos databaseCopy to Clipboard Copied! Toggle word wrap Toggle overflow In this situation, add the hostname directly to
[domain_realm]section in the/etc/krb5.confKerberos configuration file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you see the following error, you do not have any Kerberos credentials:
No Kerberos credentials available
No Kerberos credentials availableCopy to Clipboard Copied! Toggle word wrap Toggle overflow In this situation, retrieve Kerberos credentials with the
kinitutility or authenticate with SSSD:kinit idm-user@IDM.EXAMPLE.COM
[idm-user@idm-client ~]$ kinit idm-user@IDM.EXAMPLE.COM Password for idm-user@idm.example.com:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you see either of the following errors in the
/var/log/sssd/sssd_pam.loglog file, the Kerberos credentials do not match the username of the user currently logged in:User with UPN [<UPN>] was not found. UPN [<UPN>] does not match target user [<username>].
User with UPN [<UPN>] was not found. UPN [<UPN>] does not match target user [<username>].Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this situation, verify that you authenticated with SSSD, or consider disabling the
pam_gssapi_check_upnoption in the/etc/sssd/sssd.conffile:[idm-user@idm-client ~]$ cat /etc/sssd/sssd.conf ... pam_gssapi_check_upn = false
[idm-user@idm-client ~]$ cat /etc/sssd/sssd.conf ... pam_gssapi_check_upn = falseCopy to Clipboard Copied! Toggle word wrap Toggle overflow For additional troubleshooting, you can enable debugging output for the
pam_sss_gss.soPAM module.Add the
debugoption at the end of allpam_sss_gss.soentries in PAM files, such as/etc/pam.d/sudoand/etc/pam.d/sudo-i:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow Try to authenticate with the
pam_sss_gss.somodule and review the console output. In this example, the user did not have any Kerberos credentials.Copy to Clipboard Copied! Toggle word wrap Toggle overflow