Showing posts with label sssd. Show all posts
Showing posts with label sssd. Show all posts

Use realm/adcli to join RHEL7/8/9 to AD


For RHEL 7

# yum install realmd oddjob oddjob-mkhomedir sssd adcli krb5-workstation authconfig

adcli info test.com
# adcli join test.com
Password for Administrator@TEST.COM:  <---- Enter Admin password

The join operation creates an /etc/krb5.keytab keytab that the machine will authenticate with. you can run below command to show several entries
# klist -kte

Configure /etc/krb5.conf to use AD domain:

[libdefaults]
default_realm = TEST.COM
dns_lookup_realm = true
dns_lookup_kdc = true
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
udp_preference_limit  = 1

[realms]
TEST.COM = {
#kdc = ad1.test.com
#admin_server = ad1.test.com
}

[domain_realm]
.test.com = TEST.COM
test.com = TEST.COM


Use authconfig to set up the Name Service Switch (/etc/nsswitch.conf) and PAM stacks(/etc/pam.d/password-authand /etc/pam.d/system-auth):

# authconfig --enablesssd --enablesssdauth --enablelocauthorize --enablemkhomedir --update

#cat /etc/sssd/sssd.conf
[sssd]
domains = test.com

config_file_version = 2
services = nss, pam

[domain/test.com]
access_provider = simple
ad_domain = test.com
ad_gpo_access_control = permissive
ad_server = ad1.test.com, ad2.test.com
auto_private_groups = true   #all ad users have gid same as uid
cache_credentials = true
default_shell = /bin/bash
fallback_homedir = /home/%u    # same as local user home folder location
id_provider = ad
krb5_realm = TEST.COM
krb5_store_password_if_offline = true
ldap_id_mapping = true     # use id mapping from kerberos instead of postix uid/gid defintion in AD
ldap_schema = ad
ldap_user_ssh_public_key = sshPublicKey
realmd_tags = manages-system, joined-with-samba
simple_allow_groups = ssh users
use_fully_qualified_names = false

[nss]

[pam]

# chown root:root /etc/sssd/sssd.conf
# chmod 600 /etc/sssd/sssd.conf

# id username


For RHEL 8/9

# yum install realmd sssd oddjob oddjob-mkhomedir krb5-workstation authselect-compat adcli [samba-common-tools]

#realm discover example.com
#realm list
#realm join example.com
 Password for Administrator:

#authselect select sssd with-mkhomedir with-faillock without-nullok --force
#systemctl enable sssd.service --now
#systemctl enable oddjobd.service --now

A keytab is a file containing pairs of Kerberos principals and encrypted keys

[root@test1 ~]# more /etc/realmd.conf
[users]
default-home = /home/%U
default-shell = /bin/bash

[service]
automatic-install = yes

[providers]
sssd = yes

[active-directory]
default-client = sssd

[test.com]
fully-qualified-names = no
automatic-id-mapping = yes


# other commands

#realm leave
#klist -k /etc/krb5.keytab
#authconfig --test

Get openldap to authenticate with ldap server without TLS/SSL under CentOS 6


Jephe Wu - http://linuxtechres.blogspot.com

Objective: use ldap to authenticate user with openldap server without TLS/SSL
environment: CentOS 6.1 64bit (ldap client), openldap server


Concepts:

Since RHEL6/CentOS6, it uses sssd and nslcd in ldap client to authenticate with ldap server by default. And it requires TLS/SSL cert during authentication because it will transit password in plaintext otherwise.

Refer to http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/SSSD-Troubleshooting.html
----------
To perform authentication, SSSD requires that the communication channel be encrypted. This means that if sssd.conf is configured to connect over a standard protocol (ldap://), it attempts to encrypt the communication channel with Start TLS. If sssd.conf is configured to connect over a secure protocol (ldaps://), then SSSD uses SSL.

This means that the LDAP server must be configured to run in SSL or TLS. TLS must be enabled for the standard LDAP port (389) or SSL enabled on the secure LDAPS port (636). With either SSL or TLS, the LDAP server must also be configured with a valid certificate trust.
---------

Steps:

1. make sure the following packages are installed 
pam_ldap
nss_pam_ldapd  (thanks Eric to point out it, it's not underscore, it's dash)
nss-pam-ldapd

run rpm -qa  | grep ldap to check

2. modify /etc/sysconfig/authconfig
change
FORCELEGACY=no
to
FORCELEGACY=yes

3. run setup command under putty
choose 'Use LDAP' in User Information
choose 'Use Shadow Password', 'Use LDAP Authentication', 'Use Fingerprint reader' and 'Local authorization is sufficient' ,then Next
type in Server and Base DN: part such as
ldap://ldap.jephe
dc=jephewu,dc=com

Note: it will stop sssd daemon and disable it from statup by running 'chkconfig sssd off'

If you run 'setup' before changing FORCELEGACY from no to yes, it have to change it then run setup again to stop sssd, and changing /etc/pam.d/system-auth, modify all pam_sss.so to pam_ldap.so.

Note: /etc/pam.d/system-auth is a symbolic link to /etc/pam.d/system-auth-ac

4. test it
ssh as root
# getent passwd # should show all ldap users such as jwu
# getent group
# id jwu
# su - jwu


5. Troubleshooting:

a. put debug_level = 9 in /etc/sssd/sssd.conf under domain/LDAP part
or directory run
#sssd -d4 , then check /var/log/sssd/* when login.

b. nss_initgroups_ignoreusers
The LDAP server is queried even for users found in /etc/passwd.

To setup permissions correctly, the login environment needs to find all the groups that a user is a member of. If you have configured NSS to lookup groups in LDAP (group: ldap in /etc/nsswitch.conf), then the NSS library will lookup group information in LDAP for users in /etc/passwd too. To avoid this lookup for users whose group membership information is not stored on LDAP, add that user to the nss_initgroups_ignoreusers option in /etc/ldap.conf.

c. http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/SSSD-Troubleshooting.html

d. make sure you started nslcd daemon, #chconfig nslcd on

e. ldap client, unable to login as root when ldap server is down.
put the following into /etc/pam.d/system-auth after pam_unix.so line

account     required      /lib/security/$ISA/pam_unix.so
account     sufficient   /lib/security/$ISA/pam_localuser.so

f. master-slave ldap sync
A syncrepl slave LDAP server doesn't sync with the master if the sync interval is more then 35 minutes on RHEL5

6. References:
http://www.server-world.info/en/note?os=CentOS_6&p=ldap&f=2
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6-Beta/html/Deployment_Guide/SSSD-Troubleshooting.html
http://www.server-world.info/en/note?os=CentOS_6&p=ldap&f=3