From Fedora Project Wiki

Revision as of 09:15, 25 July 2013 by Jhrozek (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Use nss-pam-ldapd to gain access to trusted domain users


  1. Make sure your FreeIPA server is set up as in QA:Testcase_freeipa_trust_establish.
  2. Make sure nss-pam-ldapd is installed. This test uses RHEL-6.3 as an example, but the steps should be similar for other distribution or OS

How to test

Add test users and groups on the IPA server

When testing the legacy client, we will begin by creating a user and a group he is a member of on the server first to establish a baseline.

$ kinit admin
$ ipa user-add --first=test --last=user tuser
$ ipa group-add --desc="test group" tgroup
$ ipa group-add-member --users=tuser tgroup

Also set some password for the newly created user so that we can log in using his credentials.

$ ipa passwd tuser

Install required packages

The package installation step differs for every OS or distribution. For nss-pam-ldapd, simply install the packages using yum:

 # yum install nss-pam-ldapd pam_ldap authconfig

The authconfig utility will help us configure the PAM stack.

Configure nss-pam-ldapd and pam_ldap

Next the nss-pam-ldapd needs to be configured. The configuration will point to a "compat tree" which is a parallel LDAP tree autogenerated from the main tree and tailored so that it matches the expectations legacy clients might have. The configuration includes two important items:

  1. LDAP URI - The URI is simply the host name of the IPA server prefixed with ldap://. For example, if the hostname was, then the URI would be ldap://
  2. LDAP search base - The LDAP search base we need consists of the base DN prefixed with "cn=compat", which is the container the compat tree lives in. To get the base DN, take the IPA domain name and substitute each dot for a "dc=". For example, the IPA domain would yield base DN dc=ipa,dc=example,dc=org. The full search base you want to use would then be cn=compat,dc=ipa,dc=example,dc=org

Using authconfig

Configuring the system to authenticate with IPA using authconfig is a matter of one shell command once you know the LDAP URI and the search base.

authconfig --updateall --enableldap --enableldapauth \
           --ldapserver=ldap:// \


On systems without a helper tool such as authconfig, one needs to configure the client system manually. The configuration involves several steps:


1. configure nsswitch.conf - append ldap to the lines beginning with passwd and group.

passwd:     files ldap
group:      files ldap

2. configure PAM - configuring the PAM stack differs on particular distributions. The resulting PAM stack should look like this one:

auth        required
auth        sufficient nullok try_first_pass
auth        requisite uid >= 500 quiet
auth        sufficient use_first_pass
auth        required
account     required broken_shadow
account     sufficient
account     sufficient uid < 500 quiet
account     [default=bad success=ok user_unknown=ignore]
account     required
password    requisite try_first_pass retry=3 type=
password    sufficient sha512 shadow nullok try_first_pass use_authtok
password    sufficient use_authtok
password    required
session     optional revoke
session     required
session     [success=1 default=ignore] service in crond quiet use_uid
session     required
session     optional

3. configure nslcd.conf - The nslcd.conf config file can be pretty minimal. It just needs to include the LDAP URI and search base:

uri ldap://
base cn=compat,dc=ipatest,dc=example,dc=com

4. configure pam_ldap.conf - The pam_ldap.conf config file looks quite similar to nslcd.conf. Its minimal contents also only include the LDAP URI and the search base:

uri ldap://
base cn=compat,dc=ipatest,dc=example,dc=com

Following instructions were created using FreeBSD 9.1.

1. Install nss-pam-ldapd package. This will pull in other packages as well. We also need curl to fetch IPA master certificate:

pkg_add -r nss-pam-ldapd
pkg_add -r curl

2. Configure /etc/nsswitch.conf:

group: files ldap
passwd: files ldap

3. Configure PAM stack. Since it is done separately for each application in FreeBSD by default, we change only sshd for the test:

# $FreeBSD: release/9.1.0/etc/pam.d/sshd 197769 2009-10-05 09:28:54Z des $
# PAM configuration for the "sshd" service

# auth
auth            sufficient             no_warn no_fake_prompts
auth            requisite       no_warn allow_local
#auth           sufficient             no_warn try_first_pass
#auth           sufficient              no_warn try_first_pass
auth            sufficient      /usr/local/lib/      no_warn
auth            required             no_warn try_first_pass

# account
account         required
#account        required
account         required        /usr/local/lib/      no_warn ignore_authinfo_unavail ignore_unknown_user
account         required
account         required

# session
#session        optional              want_agent
session         required

# password
#password       sufficient             no_warn try_first_pass
password        required             no_warn try_first_pass

4. Add automated start of nslcd to /etc/rc.conf:


5. Add configuration for nslcd to /usr/local/etc/nslcd.conf, by copying /usr/local/etc/nslcd.conf.sample and changing following parameters:

uri ldap://
base cn=compat,dc=ipatest,dc=example,dc=com
scope sub
base group cn=groups,cn=compat,dc=ipatest,dc=example,dc=com
base passwd cn=users,cn=compat,dc=ipatest,dc=example,dc=com
base shadow cn=users,cn=compat,dc=ipatest,dc=example,dc=com
ssl start_tls
tls_cacertfile /usr/local/etc/ipatest.crt

6. Add partial set from above to /usr/local/etc/ldap.conf, for basic ldap libraries, note difference with tls_cacert:

uri ldap://
base cn=compat,dc=ipatest,dc=example,dc=com
ssl start_tls
tls_cacert /usr/local/etc/ipatest.crt

7. Fetch IPA certificate:

curl -k > /usr/local/etc/ipatest.crt

8. Start nslcd:

/usr/local/etc/rc.d/nslcd start

Identity lookups of IPA users and groups

Try to request data about the user that was created on the start of this test:

$ getent passwd tuser
$ getent group tgroup
$ id tuser

The commands above should reflect that tuser is member of tgroup.

Authentication as IPA user

This testcase currently does not work due to referral returned from the server.

ssh -l tuser

The error you would see would be similar to:

pam_ldap: error trying to bind as user "uid=tuser,cn=users,cn=compat,dc=ipatest,dc=example,dc=com" (Referral)

Identity lookups of trusted users and groups

When requesting the user from a trusted domain, the username must be fully qualified in the form of username@ad-domain. Additionaly, to conform with nss-pam-ldapd limitation, the username and domain name must be lowercased to match the name in the compat tree with respect to case.

To request a from the trusted domain:

$ getent passwd

Authentication as trusted user

Again, the username must be fully qualified and lowercased:

ssh -l

Note also that for FreeBSD test user names must be less than 16 characters long or actual log-in will not succeed. This is due to which is still not fixed in FreeBSD 9.1. It is recommended to create a user in Active Directory with a short name so that total name length, including the realm, will not be greater than 16 characters. For example, is 16 characters long.

Expected Results

Both users from the IPA domain and the trusted domain should be able to log in.