LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-16-2011, 04:48 PM   #1
peridian
Member
 
Registered: Jan 2010
Posts: 60

Rep: Reputation: 17
Does OpenLDAP / NSS / PAM produce logs of failed login attempts?


Hi,

I am trying to get OpenLDAP to authenticate user logins, but running around in circles. Are there any logs produced by either client and/or server that would indicate possible reasons why it was unable to login as a user?

Below is an explanation, any ideas would be appreciated, as I think everything is setup as per the various articles on using LDAP.

---

I have a CentOS 5.5 OpenLDAP server, and several others, some host services, some are file shares (samba).

So far I have been able to successfully configure OpenLDAP to carry out all the ldap* commands from both the local server and from any of the remote servers, either via non-ssl or ssl connections. However, as soon as I try connecting any services up to it, it doesn't play ball.

Back to basics, having cleared off all previous attempts at this from all machines, I have gone through the following:
  1. Installed OpenLDAP server/client on host (plus nss_ldap).
  2. Configured /etc/openldap/slapd.conf (see below)
  3. Configured /etc/openldap/ldap.conf (see below)
  4. Configured /etc/ldap.conf (see below)
  5. Configured /etc/sysconfig/iptables (see below)
  6. Started up ldap service.
  7. Ran ldapadd to input .ldif file to set up initial directory (see below)
  8. Ran ldappasswd to set password for testuser entry.
  9. Tested directory load with ldapsearch using both the admin and testuser accounts. Data returned okay on both LDAP server plus another machine.
  10. Ran authconfig-tui to configure use of LDAP for login (same machine as LDAP is on).
  11. Rechecked the above .conf files for any changes, plus /etc/nsswitch.conf (see below).
  12. Checked /etc/pam.d/system-auth (see below) *** I think this is the step where it is not working.
  13. Started nscd service (not sure this is needed) and restarted the server.
  14. Tested logging in via local console as LDAP user - Msg: Login incorrect.
  15. Tested logging in via ssh as LDAP user - Msg: Access denied.
  16. Tested logging in via either with local account - Result: Fine.
  17. Changed order in /etc/nsswitch.conf from 'files ldap' to 'ldap files'.
  18. Definite delay occurs after typing in password, even for local user account, suggesting that it is attempting communication before failing over.

/etc/openldap/slapd.conf:

Code:
include         /etc/openldap/schema/core.schema
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/inetorgperson.schema
include         /etc/openldap/schema/nis.schema
include         /etc/openldap/schema/samba.schema

allow bind_v2

pidfile         /var/run/openldap/slapd.pid
argsfile        /var/run/openldap/slapd.args

access to attrs=userPassword,sambaLMPassword,sambaNTPassword
        by self write
        by anonymous auth
        by * none
access to *
        by self write
        by users read
        by anonymous auth

database        bdb
suffix          "dc=intbus,dc=net"
rootdn          "cn=admin,dc=intbus,dc=net"
rootpw          {SSHA}<crypto removed>

directory       /var/lib/ldap

index objectClass                       eq,pres
index ou,cn,mail,surname,givenname      eq,pres,sub
index uidNumber,gidNumber,loginShell    eq,pres
index uid,memberUid                     eq,pres,sub
index nisMapName,nisMapEntry            eq,pres,sub
/etc/openldap/ldap.conf:

Code:
# Tried the below line with and without the port number
URI ldap://intbus.net:389/
BASE dc=intbus,dc=net
TLS_CACERTDIR /etc/openldap/cacerts
/etc/ldap.conf:

Code:
base dc=intbus,dc=net
# Tried the below line with and without the port number
uri ldap://intbus.net:389/
timelimit 120
bind_timelimit 120
idle_timelimit 3600
pam_filter objectclass=posixAccount
nss_base_passwd ou=Users,dc=intbus,dc=net?one
nss_base_shadow ou=Users,dc=intbus,dc=net?one
nss_base_group  ou=Groups,dc=intbus,dc=net?one
nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat,radiusd,news,mailman,nscd,gdm
ssl no
tls_cacertdir /etc/openldap/cacerts
pam_password md5
/etc/sysconfig/iptables:

Code:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 389 -s 192.168.1.0/24 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 636 -s 192.168.1.0/24 -j ACCEPT
.ldif file:

Code:
# Domain
dn: dc=intbus,dc=net
objectClass: domain
dc: intbus
description: Home domain.

# Units
dn: ou=Users,dc=intbus,dc=net
objectClass: organizationalUnit
ou: Users
description: User group.

dn: ou=Groups,dc=intbus,dc=net
objectClass: organizationalUnit
ou: Groups
description: Domain groups.

#Groups
dn: cn=sambagroup,ou=Groups,dc=intbus,dc=net
objectClass: posixGroup
cn: sambagroup
gidNumber: 3001
description: Samba file share group.

dn: cn=jiragroup,ou=Groups,dc=intbus,dc=net
objectClass: posixGroup
cn: jiragroup
gidNumber: 3002
description: Jira user group.

#Test Data
dn: cn=testGroup,ou=Groups,dc=intbus,dc=net
objectClass: posixGroup
cn: testGroup
gidNumber: 9998

dn: uid=testuser,ou=Users,dc=intbus,dc=net
objectClass: posixAccount
objectClass: person
uid: testuser
cn: testuser
sn: testuser
uidnumber: 9999
gidNumber: 9998
homedirectory: /home/testuser
/etc/pam.d/system-auth:

Code:
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 500 quiet
auth        sufficient    pam_ldap.so use_first_pass
auth        required      pam_deny.so

account     required      pam_unix.so broken_shadow
account     sufficient    pam_succeed_if.so uid < 500 quiet
account     [default=bad success=ok user_unknown=ignore] pam_ldap.so
account     required      pam_permit.so

password    requisite     pam_cracklib.so try_first_pass retry=3
password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok
password    sufficient    pam_ldap.so use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
session     optional      pam_ldap.so
/etc/nsswitch.conf:

Code:
passwd:     files ldap
shadow:     files ldap
group:      files ldap

hosts:      files dns

bootparams: nisplus [NOTFOUND=return] files

ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files

netgroup:   files ldap

publickey:  nisplus

automount:  files ldap
aliases:    files nisplus
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-16-2011, 04:56 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
ok, well the closest part to the user login attempt is /var/log/secure on the server in question, this is pam's output, not ldaps so covers the generic act of logging in. Or not. On the ldap side, then you should have /var/log/ldap or something similar on the ldap server, although tbh I needed to add a syslog entry for local4.* to tell it to write to the ldap log file (nothing else on my servers use local4, and it's slapd's default so works fine...) In there you'd then be able to see all communications, and you've got two "normal" error codes to look for on a bind attempt for authentication purposes, err=49 which is "invalid credentials" which principally means a wrong password, but also covers expired ones and a few other subtleties, and also err=19 which is "constraint violation" which is locked out accounts from successive failed attempts etc. Plenty of other reasons, e.g. broken / malformed accounts etc, but those two are from my experience, the main user level codes. Also in terms of troubleshooting, wireshark is so so useful to capture the network traffic (disable TLS / SSL temporarily first) so you can actually see the full breakdown of the comms between client and ldap server, which can shed huge amounts of information too. A further demarcation thang is to ensure that "getent passwd" also works for user information. It's no good giving the right password if the system doens't even know the account exists, and that's directly using nsswitch.conf and /etc/ldap.conf and (afaik) nothing else significant at all, so can easily help localise an issue.

Last edited by acid_kewpie; 02-16-2011 at 04:58 PM.
 
2 members found this post helpful.
Old 02-17-2011, 03:51 PM   #3
peridian
Member
 
Registered: Jan 2010
Posts: 60

Original Poster
Rep: Reputation: 17
Thanks a lot, that pointed me exactly where I needed.

A bit of trial and error, some research, and I got it working.

The problem was that I had not specified a rootbinddn (despite some articles saying it is not required). My previous attempts to add a rootbinddn had failed because I had left out the ou=Users part of the dn, or at one point because I had reset the ldif file entries without setting the password.

Onwards and upwards... hopefully.

Cheers,
Rob.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PAM, pam_tally, and locking out users after 3 failed login attempts in RHEL5 frail.knight Linux - Security 10 03-17-2011 04:06 PM
ssh logs show numerous failed attempts schneidz Linux - Security 12 06-22-2009 01:30 PM
OpenLDAP SSL/TLS problem with pam/nss humbletech99 Linux - Server 0 06-12-2009 07:39 AM
SSH/PAM non-authorized login attempts: print default message kenneho Linux - Security 0 01-08-2009 08:42 AM
What logs to check for attempted login attempts htmlcoder Linux - Security 2 03-05-2005 11:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration