ccaero
Goto Top

OpenLDAP - Anmeldung auf Client mit beliebigen oder ohne Passwort möglich ...

Ich habe habe auf meinem Debian-Lenny-Server einen OpenLDAP-Server augesetzt und möchte mich von einem Linux-Client über LDAP-Anmelden.
Die Installation der Komponeten hat problemlos funktioniert.
Allerdings akzeptiert der Client jedes x-beliebiges Password als gültiges LDAP-Password (egal ob korrekt oder nicht).
Als Client verwende ich ebenfalls Debian Lenny mit libnss-ldap und libpam-ldap.

Hallo,

ich habe in meinem LAN auf meinem Debian-Lenny-Server einen OpenLDAP-Server installiert.
LDAP möchte ich später als Backend für SAMBA verwenden, sowie als Benutzer-Datenbank für Linux-Clients.
Später möchte ich auch DNS und DHCP ins LDAP integrieren.

Fürn Anfang reicht mir schon mal wenn die Anmeldung auf Linux-Clients per LDAP funktioniert.

Den LDAP-Server habe ich mit "apt-get install slapd ldap-utils" installiert und anschließend mit "dpkg-reconfigure slapd" konfiguriert.
Anschließend habe ich noch einige kleinigkeiten händisch an der slapd.conf geändernt (Schemate hinzugefügt, Root-DN angepasst).

Der Server startet einwandfrei und ich kann auch mit den ldap-utils sowie mit JXplorer drauf zugreifen und als Admin auch änderungen durchführen.


Danach habe ich ein frischen Debian Lenny in einer VM augesetzte (Standart-Installation ohne GUI) und mit
"apt-get install libnss-ldapd" den LDAP-Client installiert und gleich konfiguriert.

nscd habe ich gleich mit "apt-get purge nscd" wieder gelöscht um Fehlerquellen mal von vornhinein auszuschließen.
Die "/etc/nsswitch.conf" wurde durch das LDAP-Client-Setup bereits korrekt eingestellt (bei passwd, groups und shadow "ldap" hinzugefügt), so das ich hier nicht nacharbeiten hab müssen.
Nur die Config-Datein "common-auth" "common-account" "common-session" und "common-password" im Ordner "/etc/pam.d" habe ich manuell bearbeiten müssen.

Sicherheitshalber habe ich nach den Änderungen die Client-VM neugestartet.
Nach dem Neustart habe ich gleich versucht mich mit meinem neu angelegten LDAP-User "testuser" einzuloggen, was auch wunderbar funktioniert hat.
"getent passwd" und "getent groups" zeigen auch die LDAP-User und Gruppen korrekt an.

Allerding, habe ich bemerkt das der Login mit dem User "testuser" mit jedem X-bliebigen Passwort funktioniert und das schmeißt natürlich jedes Sicherheitskonzept in den Kübel.
Auch der Befehl "passswd" liefert einen Fehler:
"passwd: Berechtigung verweigert
passwd: password unchanged"
Einloggen per SSH auf die Client-Maschine funktioniert auch nicht ("Access denied" nach der Password-Eingabe).

Hier mal meine Config-Dateien:

"/etc/nss-client.conf" auf Client:
# nss-ldapd configuration file. See nss-ldapd.conf(5)
# for details.

# The user and group nslcd should run as.
uid nslcd
gid nslcd

# The location at which the LDAP server(s) should be reachable.
uri ldap://mastertux.cc-network.at/

# The search base that will be used for all queries.
base dc=cc-network,dc=at

# The LDAP protocol version to use.
#ldap_version 3

# The DN to bind with for normal lookups.
#binddn cn=annonymous,dc=example,dc=net
#bindpw secret

# The search scope.
#scope sub

"/etc/pam_ldap.conf" auf Client
# the configuration of this file will be done by debconf as long as the
# first line of the file says '###DEBCONF###' 
#
# you should use dpkg-reconfigure to configure this file
#
# @(#)$Id: pam_ldap.conf,v 1.38 2006/05/15 08:13:31 lukeh Exp $
#
# This is the configuration file for the LDAP nameservice
# switch library and the LDAP PAM module.
#
# PADL Software
# http://www.padl.com
#

# Your LDAP server. Must be resolvable without using LDAP.
# Multiple hosts may be specified, each separated by a 
# space. How long nss_ldap takes to failover depends on
# whether your LDAP client library supports configurable
# network or connect timeouts (see bind_timelimit).
#host 127.0.0.1

# The distinguished name of the search base.
base dc=cc-network,dc=at

# Another way to specify your LDAP server is to provide an
uri ldapi://mastertux.cc-network.at/
# Unix Domain Sockets to connect to a local LDAP Server.
#uri ldap://127.0.0.1/
#uri ldaps://127.0.0.1/   
#uri ldapi://%2fvar%2frun%2fldapi_sock/
# Note: %2f encodes the '/' used as directory separator  

# The LDAP version to use (defaults to 3
# if supported by client library)
ldap_version 3

# Check the 'authorizedService' attribute for access  
# control
# Default is no; if set to yes, and the user has no
# value for the authorizedService attribute, and
# pam_ldap is configured for account management
# (authorization) then the user will not be allowed
# to login.
pam_check_service_attr yes

# HEADS UP: the pam_crypt, pam_nds_passwd,
# and pam_ad_passwd options are no
# longer supported.
#
# Do not hash the password at all; presume
# the directory server will do it, if
# necessary. This is the default.
pam_password crypt

"/etc/pam.d/common-auth" auf Client
#
# /etc/pam.d/common-auth - authentication settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authentication modules that define
# the central authentication scheme for use on the system
# (e.g., /etc/shadow, LDAP, Kerberos, etc.).  The default is to use the
# traditional Unix authentication mechanisms.
#
auth	sufficient	pam_unix.so nullok_secure
auth	sufficient	pam_ldap.so

"/etc/pam.d/common-account" auf Client
#
# /etc/pam.d/common-account - authorization settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authorization modules that define
# the central access policy for use on the system.  The default is to
# only deny service to users whose accounts are expired in /etc/shadow.
#
account sufficient	pam_ldap.so
account	sufficient	pam_unix.so

"/etc/pam.d/common-session" auf Client
#
# /etc/pam.d/common-session - session-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define tasks to be performed
# at the start and end of sessions of *any* kind (both interactive and
# non-interactive).  The default is pam_unix.
#
session sufficient	pam_ldap.so
session	sufficient	pam_unix.so

"/etc/pam.d/common-password" auf Client
#
# /etc/pam.d/common-password - password-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define the services to be
# used to change user passwords.  The default is pam_unix.

# Explanation of pam_unix options:
#
# The "nullok" option allows users to change an empty password, else  
# empty passwords are treated as locked accounts.
#
# The "md5" option enables MD5 passwords.  Without this option, the  
# default is Unix crypt.
#
# The "obscure" option replaces the old `OBSCURE_CHECKS_ENAB' option in  
# login.defs.
#
# You can also use the "min" option to enforce the length of the new  
# password.
#
# See the pam_unix manpage for other options.

password   sufficient	pam_unix.so nullok obscure md5
password   sufficient	pam_ldap.so

# Alternate strength checking for password. Note that this
# requires the libpam-cracklib package to be installed.
# You will need to comment out the password line above and
# uncomment the next two in order to use this.
# (Replaces the `OBSCURE_CHECKS_ENAB', `CRACKLIB_DICTPATH')  
#
# password required	  pam_cracklib.so retry=3 minlen=6 difok=3
# password required	  pam_unix.so use_authtok nullok md5


"/etc/ldap/slapd.conf" auf Server
# This is the main slapd configuration file. See slapd.conf(5) for more
# info on the configuration options.

#######################################################################
# Global Directives:

# Features to permit
#allow bind_v2

# Schema and objectClass definitions
include         /etc/ldap/schema/core.schema
include         /etc/ldap/schema/cosine.schema
include         /etc/ldap/schema/nis.schema
include         /etc/ldap/schema/inetorgperson.schema
include		/etc/ldap/schema/samba.schema
include		/etc/ldap/schema/misc.schema

# Where the pid file is put. The init.d script
# will not stop the server if you change this.
pidfile         /var/run/slapd/slapd.pid

# List of arguments that were passed to the server
argsfile        /var/run/slapd/slapd.args

# Read slapd.conf(5) for possible values
loglevel        none

# Where the dynamically loaded modules are stored
modulepath	/usr/lib/ldap
moduleload	back_hdb

# The maximum number of entries that is returned for a search operation
sizelimit 500

# The tool-threads parameter sets the actual amount of cpu's that is used 
# for indexing.
tool-threads 1

#######################################################################
# Specific Backend Directives for hdb:
# Backend specific directives apply to this backend until another
# 'backend' directive occurs 
backend		hdb

#######################################################################
# Specific Backend Directives for 'other': 
# Backend specific directives apply to this backend until another
# 'backend' directive occurs 
#backend		<other>

#######################################################################
# Specific Directives for database #1, of type hdb:
# Database specific directives apply to this databasse until another
# 'database' directive occurs 
database        hdb

# The base of your directory in database #1
suffix          "dc=cc-network,dc=at"  

# rootdn directive for specifying a superuser on the database. This is needed
# for syncrepl.
rootdn          "cn=admin,ou=special,dc=cc-network,dc=at"  
rootpw		xxx


# Where the database file are physically stored for database #1
directory       "/var/lib/ldap"  

# The dbconfig settings are used to generate a DB_CONFIG file the first
# time slapd starts.  They do NOT override existing an existing DB_CONFIG
# file.  You should therefore change these settings in DB_CONFIG directly
# or remove DB_CONFIG and restart slapd for changes to take effect.

# For the Debian package we use 2MB as default but be sure to update this
# value if you have plenty of RAM
dbconfig set_cachesize 0 2097152 0

# Sven Hartge reported that he had to set this value incredibly high
# to get slapd running at all. See http:{{comment_single_line_double_slash:0}}
# information.

# Number of objects that can be locked at the same time.
dbconfig set_lk_max_objects 1500
# Number of locks (both requested and granted)
dbconfig set_lk_max_locks 1500
# Number of lockers
dbconfig set_lk_max_lockers 1500

# Indexing options for database #1
index           objectClass eq

# Save the time that the entry gets modified, for database #1
lastmod         on

# Checkpoint the BerkeleyDB database periodically in case of system
# failure and to speed slapd shutdown.
checkpoint      512 30

# Where to store the replica logs for database #1
# replogfile	/var/lib/ldap/replog

# The userPassword by default can be changed
# by the entry owning it if they are authenticated.
# Others should not be able to see it, except the
# admin entry below
# These access lines apply to database #1 only
access to attrs=userPassword,shadowLastChange
        by dn="cn=admin,ou=special,dc=cc-network,dc=at" write  
        by anonymous auth
        by self write
        by * none

# Ensure read access to the base for things like
# supportedSASLMechanisms.  Without this you may
# have problems with SASL not knowing what
# mechanisms are available and the like.
# Note that this is covered by the 'access to *' 
# ACL below too but if you change that as people
# are wont to do you'll still need this if you 
# want SASL (and possible other things) to work 
# happily.
access to dn.base="" by * read  

# The admin dn has full write access, everyone else
# can read everything.
access to *
        by dn="cn=admin,ou=special,dc=cc-network,dc=at" write  
        by * read

# For Netscape Roaming support, each user gets a roaming
# profile for which they have write access to
#access to dn=".*,ou=Roaming,o=morsnet" 
#        by dn="cn=admin,ou=special,dc=cc-network,dc=at" write 
#        by dnattr=owner write

#######################################################################
# Specific Directives for database #2, of type 'other' (can be hdb too): 
# Database specific directives apply to this databasse until another
# 'database' directive occurs 
#database        <other>

# The base of your directory for database #2
#suffix		"dc=debian,dc=org" 

Und jetzt noch die Struktur meines LDAP-Test.Verzeichniss aus ldif-Export:
version: 1
dn: dc=cc-network,dc=at
objectClass: top
objectClass: dcObject
objectClass: organization
dc: cc-network
o: cc-network.at

dn: ou=birkenweg2,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Standort Birkenweg 2 Hollabrunn
ou: birkenweg2

dn: ou=users,ou=birkenweg2,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Birkenweg2 Benutzer
ou: users

dn: uid=testuser,ou=users,ou=birkenweg2,dc=cc-network,dc=at
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: posixAccount
objectClass: shadowAccount
objectClass: person
objectClass: top
cn: testuser
gidNumber: 1500
givenName: Test
homeDirectory: /home/testuser
loginShell: /bin/bash
sn: User
uid: testuser
uidNumber: 1200
userPassword:: xxx

dn: ou=groups,ou=birkenweg2,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Birkenweg2 Gruppen
ou: groups

dn: cn=users,ou=groups,ou=birkenweg2,dc=cc-network,dc=at
objectClass: posixGroup
objectClass: top
cn: users
gidNumber: 1500

dn: ou=computers,ou=birkenweg2,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Birkenweg2 SAMBA Maschinenaccounts
ou: computers

dn: ou=internet,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Container fuer externe User
ou: internet

dn: ou=users,ou=internet,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Externe Benutzer
ou: users

dn: ou=groups,ou=internet,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Externe Gruppen
ou: groups

dn: ou=special,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Container fuer Spezialobjekte
ou: special

dn: cn=admin,ou=special,dc=cc-network,dc=at
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword:: xxx

dn: cn=proxyuser,ou=special,dc=cc-network,dc=at
objectClass: simpleSecurityObject
objectClass: organizationalRole
objectClass: top
cn: proxyuser
description:: VXNlciBmw7xyIGFub255bWUgTERBUC1BYmZyYWdlbg==
userPassword:: xxx

dn: ou=service,dc=cc-network,dc=at
objectClass: organizationalUnit
description: Container fuer Dienstobjecte
ou: service

Die Passwörter sind als SSHA abgelegt, hier habe ich sie ausgeblendet.

Hätte vl hier jemand eine Idee wo das Problem liegen könnte? Ich vermute das das Problem an PAM liegt, nur mit PAM habe ich leider nicht soviel Erfahrung.

Danke im vorraus ;)

Content-Key: 154708

Url: https://administrator.de/contentid/154708

Printed on: April 23, 2024 at 21:04 o'clock