OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Password

Einrichten des lokalen Netzes, Verbindung zu anderen Computern und Diensten.
Antworten
ccaero
Beiträge: 9
Registriert: 10.11.2010 12:57:34

OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Password

Beitrag von ccaero » 10.11.2010 13:00:24

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).

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 :wink:

mtheiss
Beiträge: 154
Registriert: 01.04.2005 22:07:26
Lizenz eigener Beiträge: MIT Lizenz

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von mtheiss » 10.11.2010 14:13:19

Hallo,

zeig uns doch mal deine editierten common-* Dateien. Ich vermute da ist der Fehler begraben (genauer gesagt in der common-auth)

Gruss
Martin

ccaero
Beiträge: 9
Registriert: 10.11.2010 12:57:34

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von ccaero » 10.11.2010 14:25:41

okay,

hier die common-auth:

Code: Alles auswählen

#
# /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
common-account:

Code: Alles auswählen

#
# /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
common-session:

Code: Alles auswählen

#
# /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
und common-password:

Code: Alles auswählen

#
# /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

mtheiss
Beiträge: 154
Registriert: 01.04.2005 22:07:26
Lizenz eigener Beiträge: MIT Lizenz

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von mtheiss » 10.11.2010 14:51:40

Hallo
http://snow.nl/dist/xhtmlc/ch10s04.html
Schau dir nochmal die Erklärung des control Feldes an.

common-auth

Code: Alles auswählen

    #
    # /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   required   pam_unix.so nullok_secure
    auth   sufficient   pam_ldap.so
Du solltest mindestens ein Modul als required drin haben, da fehlgeschlagen sufficient Module das Endergebnis nicht beeinflussen. Wenn es nur 2 Module mit sufficient gibt, könnte man auch genausogut nichts reinschreiben, was dann einem Erfolg ohne irgendwas gleichkommt.

ccaero
Beiträge: 9
Registriert: 10.11.2010 12:57:34

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von ccaero » 10.11.2010 15:08:40

hmmm ... ich hätte das Schlüsselwort "sufficient" so zu sagen als "oder"-Bedingung aufgefasst, also das die Prozedur erfolgreich ist, wenn einer der beiden Bedinungen erfolgreich durchgegangen ist :?

Ich werd das Schlüsselwort "required" mal ausprobieren, danke mal für den Tipp :)

ccaero
Beiträge: 9
Registriert: 10.11.2010 12:57:34

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von ccaero » 10.11.2010 19:59:06

Hmm ... Der Tipp hat leider auch nicht funktionier, ich hab dann noch versucht die Dateien so anzupassen:

account:

Code: Alles auswählen

# /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 required        pam_unix.so
auth:

Code: Alles auswählen

#
# /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_ldap.so
auth    required        pam_unix.so nullok_secure
wenn ich diese Einstellungen verwende funktioniert der Login mit dem LDAP-User gar nicht "Login incorrect".

vl kann man was aus der Auth.log herauslesen (direkt nach dem Start):

Code: Alles auswählen

Nov 10 19:49:54 lnx-tst-clnt sshd[2114]: Server listening on :: port 22.
Nov 10 19:49:54 lnx-tst-clnt sshd[2114]: Server listening on 0.0.0.0 port 22.
Nov 10 19:50:00 lnx-tst-clnt sshd[2114]: Received signal 15; terminating.
Nov 10 19:50:00 lnx-tst-clnt sshd[2502]: Server listening on :: port 22.
Nov 10 19:50:00 lnx-tst-clnt sshd[2502]: Server listening on 0.0.0.0 port 22.
Nov 10 19:50:06 lnx-tst-clnt login[2449]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:50:06 lnx-tst-clnt login[2449]: pam_ldap: reconnecting to LDAP server...
Nov 10 19:50:06 lnx-tst-clnt login[2449]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:50:08 lnx-tst-clnt login[2449]: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=tty1 ruser= rhost=  user=testuser
Nov 10 19:50:11 lnx-tst-clnt login[2449]: FAILED LOGIN (1) on 'tty1' FOR `testuser', Authentication failure
Nov 10 19:50:16 lnx-tst-clnt login[2449]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:50:16 lnx-tst-clnt login[2449]: pam_ldap: reconnecting to LDAP server...
Nov 10 19:50:16 lnx-tst-clnt login[2449]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:50:19 lnx-tst-clnt login[2449]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:50:19 lnx-tst-clnt login[2449]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:50:19 lnx-tst-clnt login[2449]: pam_ldap: reconnecting to LDAP server...
Nov 10 19:50:19 lnx-tst-clnt login[2449]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:50:19 lnx-tst-clnt login[2503]: ROOT LOGIN  on 'tty1'
Nov 10 19:55:38 lnx-tst-clnt sshd[2520]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:55:38 lnx-tst-clnt sshd[2520]: pam_ldap: reconnecting to LDAP server...
Nov 10 19:55:38 lnx-tst-clnt sshd[2520]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:55:38 lnx-tst-clnt sshd[2520]: pam_ldap: ldap_simple_bind Can't contact LDAP server
Nov 10 19:55:38 lnx-tst-clnt sshd[2520]: pam_ldap: reconnecting to LDAP server...
Nov 10 19:55:38 lnx-tst-clnt sshd[2520]: pam_ldap: ldap_simple_bind Can't contact LDAP server

mtheiss
Beiträge: 154
Registriert: 01.04.2005 22:07:26
Lizenz eigener Beiträge: MIT Lizenz

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von mtheiss » 11.11.2010 13:05:19

Hallo,

da kann man ja schön erkennen, dass er sich nicht zum LDAP Server verbinden kann.

Stehen in /etc/pam_ldap.conf die richtigen Werte zum Verbinden drinnen? (siehe man 5 pam_ldap.conf)

Gruss
Martin

ccaero
Beiträge: 9
Registriert: 10.11.2010 12:57:34

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von ccaero » 13.11.2010 15:06:06

super jetzt funktionierts.

Der Fehler lag tatsächlich in der pam_ldap.conf.

dpgk-recofigure hat als Serveradresse lapi://mastertux.cc-network.at/ eingetragen.
ich habe diese Zeile auskommentiert und stattdesen die "Parametet" host und port verwenden und siehe da es funktioniert, auch der Password wechsel, thx :)

ccaero
Beiträge: 9
Registriert: 10.11.2010 12:57:34

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von ccaero » 15.11.2010 08:59:49

okay, ldap-auth am client und auch am server selbst funktioniert jetzt.
Nur bin ich auf ein weiteres Problem gestoßen, eigentlich nur ein Schönheitsfehler.

Die motd und Mail-Benachrichtigung werden nach dem Login nicht mehr angezeigt, auch nicht wenn der login über ssh erfolgt.
Die beiden Dinge werden doch auch über pam gesteuert, nur verstehe ich nicht warum sie nach hinzufügen der LDAP-Module nicht mehr funktionieren o.O

mtheiss
Beiträge: 154
Registriert: 01.04.2005 22:07:26
Lizenz eigener Beiträge: MIT Lizenz

Re: OpenLDAP-Anmeldung auf Client mit belieb. oder ohne Pass

Beitrag von mtheiss » 15.11.2010 14:05:32

Hi,

poste uns für das Problem mal deine /etc/pam.d/ssh
Dort wird defaultmässig pam_motd als optionales Sessionmodul eingebunden.

Gruss
Martin

Antworten