Autenticazione LDAP su CentOS 7


11

Dopo l'aggiornamento a CentOS 7 non è più possibile accedere tramite LDAP. Con CentOS 6 ho usato il pacchetto pam_ldap che ha funzionato bene, ma ora pam_ldap non è più disponibile per la nuova versione di CentOS.

La connessione tramite ldapsearch funziona ancora bene, ma il tentativo di autenticazione tramite ssh non funziona.

Ho reinstallato il pacchetto nss-pam-ldapd e riconfigurato l'autenticazione tramite authconfig-tui , ma non funziona ancora.

Di seguito sostituisco il mio nome utente con user.name e la base con dc = sub, dc = esempio, dc = org .

Il mio sistema operativo host è CentOS 7. Tutti gli aggiornamenti attualmente disponibili sono installati.

$ uname -a
Linux isfet 3.10.0-123.8.1.el7.x86_64 #1 SMP Mon Sep 22 19:06:58 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Pacchetti installati

$ rpm -qa | grep -i ldap
openldap-2.4.39-3.el7.x86_64
nss-pam-ldapd-0.8.13-8.el7.x86_64
openldap-clients-2.4.39-3.el7.x86_64

Contenuto di /etc/openldap/ldap.conf

URI ldap://172.16.64.25
BASE dc=sub,dc=example,dc=org

Contenuto di /etc/nslcd.conf

ldap_version 3
uri ldap://172.16.64.25
base dc=sub,dc=example,dc=org
ssl no

Uscita di / var / log / secure

Oct  6 12:12:16 isfet sshd[3937]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=172.16.64.1  user=user.name
Oct  6 12:12:17 isfet sshd[3937]: Failed password for user.name from 172.16.64.1 port 18877 ssh2

Output di /var/log/audit/audit.log

type=USER_AUTH msg=audit(1412590243.286:364): pid=3912 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:authentication acct="user.name" exe="/usr/sbin/sshd" hostname=172.16.64.1 addr=172.16.64.1 terminal=ssh res=failed'
type=USER_AUTH msg=audit(1412590243.287:365): pid=3912 uid=0 auid=4294967295 ses=4294967295 msg='op=password acct="user.name" exe="/usr/sbin/sshd" hostname=? addr=172.16.64.1 terminal=ssh res=failed'

Uscita del comando ldapserach

$ ldapsearch -H ldap://172.16.64.25/ -D cn=Manager,dc=sub,dc=example,dc=org -W -x -b dc=sub,dc=example,dc=org -d1

ldap_url_parse_ext(ldap://172.16.64.25/)
ldap_create
ldap_url_parse_ext(ldap://172.16.64.25:389/??base)
Enter LDAP Password:
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP 172.16.64.25:389
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying 172.16.64.25:389
ldap_pvt_connect: fd: 3 tm: -1 async: 0
attempting to connect:
connect success
ldap_open_defconn: successful
ldap_send_server_request
ber_scanf fmt ({it) ber:
ber_scanf fmt ({i) ber:
ber_flush2: 61 bytes to sd 3
ldap_result ld 0x7f9b07402110 msgid 1
wait4msg ld 0x7f9b07402110 msgid 1 (infinite timeout)
wait4msg continue ld 0x7f9b07402110 msgid 1 all 1
** ld 0x7f9b07402110 Connections:
* host: 172.16.64.25  port: 389  (default)
  refcnt: 2  status: Connected
  last used: Mon Oct  6 12:04:38 2014


** ld 0x7f9b07402110 Outstanding Requests:
 * msgid 1,  origid 1, status InProgress
   outstanding referrals 0, parent count 0
  ld 0x7f9b07402110 request count 1 (abandoned 0)
** ld 0x7f9b07402110 Response Queue:
   Empty
  ld 0x7f9b07402110 response count 0
ldap_chkResponseList ld 0x7f9b07402110 msgid 1 all 1
ldap_chkResponseList returns ld 0x7f9b07402110 NULL
ldap_int_select
read1msg: ld 0x7f9b07402110 msgid 1 all 1
ber_get_next
ber_get_next: tag 0x30 len 50 contents:
read1msg: ld 0x7f9b07402110 msgid 1 message type bind
ber_scanf fmt ({eAA) ber:
read1msg: ld 0x7f9b07402110 0 new referrals
read1msg:  mark request completed, ld 0x7f9b07402110 msgid 1
request done: ld 0x7f9b07402110 msgid 1
res_errno: 0, res_error: <>, res_matched: <cn=Manager,dc=sub,dc=example,dc=org>
ldap_free_request (origid 1, msgid 1)
ldap_parse_result
ber_scanf fmt ({iAA) ber:
ber_scanf fmt (}) ber:
ldap_msgfree
ldap_err2string
ldap_bind: Success (0)
        matched DN: cn=Manager,dc=sub,dc=example,dc=org
...

Contenuto di _ / etc / pam.d / password-auth

auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 1000 quiet_success
auth        sufficient    pam_ldap.so use_first_pass
auth        required      pam_deny.so

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

password    requisite     pam_pwquality.so try_first_pass retry=3 type=
password    sufficient    pam_unix.so sha512 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     optional      pam_systemd.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

Contenuto di _ / etc / pam.d / system-auth

auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 1000 quiet_success
auth        sufficient    pam_ldap.so use_first_pass
auth        required      pam_deny.so

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

password    requisite     pam_pwquality.so try_first_pass retry=3 type=
password    sufficient    pam_unix.so sha512 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     optional      pam_systemd.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

Si ottengono risultati eseguendo "getent passwd user.name" o "su - user.name"?
— Andy,

L'utente esiste localmente, ma senza password. L'autenticazione è contro LDAP. / etc / passwd: user.name:x:1028:1031::/home/user.name:/bin/bash / etc / shadow: user.name: !!: 16348: 0: 99999: 7 :::
— Lukas Schulze,

Non pam_ldaputilizza un file diverso da /etc/openldap/ldap.conf? Voglio dire /etc/ldap.conf, con disinvoltura. debugProverei a eseguire il debug del modulo aggiungendo l' opzione per l'aggiunta del verbosiry di registrazione, ad es auth sufficient pam_ldap.so use_first_pass debug. Oltre a ciò, penso che la domanda sia stata confusa da te seguendo il consiglio di Joffrey. Si prega di ripristinare la configurazione originale se si desidera che altri possano aiutarti.
— Andrew B,

Puoi aggiungere il contenuto di /etc/ldap.conf?
— Andrew B,

Grazie! L'esecuzione di nslcd in modalità debug mi ha aiutato a trovare l'errore. L'ho scritto come una risposta.
— Lukas Schulze,

Risposte:


4

L'esecuzione di nslcd in modalità debug mostra il problema:

$ $(which nslcd) -d
...
nslcd: [8b4567] <authc="user.name"> DEBUG: myldap_search(base="dc=sub,dc=example,dc=org", filter="(&(objectClass=posixAccount)(uid=user.name))")
...
nslcd: [8b4567] <authc="user.name"> DEBUG: ldap_result(): end of results (0 total)
nslcd: [8b4567] <authc="user.name"> DEBUG: "user.name": user not found: No such object
...

nslcd imposta un filtro per impostazione predefinita. Non è possibile rimuovere questo filtro o impostarlo su vuoto.

Poiché nessuno dei miei utenti LDAP ha una objectClass chiamata posixAccount, gli utenti non possono essere trovati e l'accesso negato.

Per risolvere questo problema ho dovuto sovrascrivere questo filtro con uno proprio. Poiché sto cercando l' UID , è utile impostare il filtro su un attributo che viene comunque cercato.

Nuovo contenuto del mio /etc/nslcd.conf :

filter passwd (uid=*)
uri ldap://172.16.64.25
base dc=sub,dc=example,dc=org
ssl no

Dopo aver cambiato nslcd.conf ho dovuto riavviare il servizio nslcd:systemctl restart nslcd

Fonte: http://lists.arthurdejong.org/nss-pam-ldapd-users/2014/msg00025.html

.

Questo sembra essere un problema per _nss-pam-ldapd-0.8.13-8.el7.x86_64_ su CentOS 7!

$ nslcd -V
nss-pam-ldapd 0.8.13

Ho provato a riprodurre il problema su CentOS 6, ma su questo nss-pam-ldapd ha dipendenze da pam_ldap che ha il suo file di configurazione in /etc/pam_ldap.conf e sembra non usare /etc/nslcd.conf nel modo in cui funziona su CentOS 7.


1
Sì, le pam_ldapcollisioni di denominazione sono molto confuse. :( Esistono molteplici implementazioni che tutti rivendicano il nome di quel modulo.
— Andrew B
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.