Autenticação PAM / LDAP com o Ubuntu 10.04

3

Eu não posso envolver meu cérebro em torno da nova sintaxe de configuração pam.d usada no Ubuntu 10.04. Como configuro o PAM para permitir que usuários armazenados em meu banco de dados LDAP efetuem login?

Eu já configurei o nscd, então id <user> ou getent passwd já estão listando meus usuários LDAP, mas o PAM não funciona, seja o login normal do shell nem su .

Atualização de 17 de junho de 2010 às 18:45

O LDAP já está funcionando. Eu posso listar todas as contas executando getent passwd , mas minha configuração do PAM ainda não está funcionando.

A listagem abaixo mostra meu /etc/pam.d/login

#
# The PAM configuration file for the Shadow 'login' service
#

# Enforce a minimal delay in case of failure (in microseconds).
# (Replaces the 'FAIL_DELAY' setting from login.defs)
# Note that other modules may require another minimal delay. (for example,
# to disable any delay, you should add the nodelay option to pam_unix)
auth       optional   pam_faildelay.so  delay=3000000

# Outputs an issue file prior to each login prompt (Replaces the
# ISSUE_FILE option from login.defs). Uncomment for use
# auth       required   pam_issue.so issue=/etc/issue

# Disallows root logins except on tty's listed in /etc/securetty
# (Replaces the 'CONSOLE' setting from login.defs)
# Note that it is included as a "required" module. root will be
# prompted for a password on insecure ttys.
# If you change it to a "requisite" module, make sure this does not leak
# user name information.
auth       required  pam_securetty.so

# Disallows other than root logins when /etc/nologin exists
# (Replaces the 'NOLOGINS_FILE' option from login.defs)
auth       requisite  pam_nologin.so

# SELinux needs to be the first session rule. This ensures that any 
# lingering context has been cleared. Without out this it is possible 
# that a module could execute code in the wrong domain.
# When the module is present, "required" would be sufficient (When SELinux
# is disabled, this returns success.)
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close

# This module parses environment configuration file(s)
# and also allows you to use an extended config
# file /etc/security/pam_env.conf.
# 
# parsing /etc/environment needs "readenv=1"
session       required   pam_env.so readenv=1
# locale variables are also kept into /etc/default/locale in etch
# reading this file *in addition to /etc/environment* does not hurt
session       required   pam_env.so readenv=1 envfile=/etc/default/locale

# Standard Un*x authentication.
@include common-auth

# This allows certain extra groups to be granted to a user
# based on things like time of day, tty, service, and user.
# Please edit /etc/security/group.conf to fit your needs
# (Replaces the 'CONSOLE_GROUPS' option in login.defs)
auth       optional   pam_group.so

# Uncomment and edit /etc/security/time.conf if you need to set
# time restrainst on logins.
# (Replaces the 'PORTTIME_CHECKS_ENAB' option from login.defs
# as well as /etc/porttime)
# account    requisite  pam_time.so

# Uncomment and edit /etc/security/access.conf if you need to
# set access limits.
# (Replaces /etc/login.access file)
# account  required       pam_access.so

# Sets up user limits according to /etc/security/limits.conf
# (Replaces the use of /etc/limits in old login)
session    required   pam_limits.so

# Prints the last login info upon succesful login
# (Replaces the 'LASTLOG_ENAB' option from login.defs)
session    optional   pam_lastlog.so

# Prints the motd upon succesful login
# (Replaces the 'MOTD_FILE' option in login.defs)
session    optional   pam_motd.so

# Prints the status of the user's mailbox upon succesful login
# (Replaces the 'MAIL_CHECK_ENAB' option from login.defs). 
#
# This also defines the MAIL environment variable
# However, userdel also needs MAIL_DIR and MAIL_FILE variables
# in /etc/login.defs to make sure that removing a user 
# also removes the user's mail spool file.
# See comments in /etc/login.defs
session    optional   pam_mail.so standard

# Standard Un*x account and session
@include common-account
@include common-session
@include common-password

# SELinux needs to intervene at login time to ensure that the process
# starts in the proper default security context. Only sessions which are
# intended to run in the user's context should be run after this.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
# When the module is present, "required" would be sufficient (When SELinux
# is disabled, this returns success.)

A listagem abaixo mostra meu /etc/pam.d/common-auth

#
# /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.
#
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
# To take advantage of this, it is recommended that you configure any
# local modules either before or after the default block, and use
# pam-auth-update to manage selection of other modules.  See
# pam-auth-update(8) for details.

# here are the per-package modules (the "Primary" block)
auth    [success=2 default=ignore]  pam_unix.so nullok_secure
auth    [success=1 default=ignore]  pam_ldap.so use_first_pass
# here's the fallback if no module succeeds
auth    requisite           pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth    required            pam_permit.so
# and here are more per-package modules (the "Additional" block)
# end of pam-auth-update config
    
por t6d 17.06.2010 / 16:54

2 respostas

0

Restaurar seus arquivos pam para as versões originais. Instale o pacote libnss-ldap que integrará o acesso do ldap ao pam. Você também pode querer instalar o nscd.

Configure seu servidor em /etc/ldap.conf.

Edite o /etc/nsswitch.conf adicionando o ldap ao final das linhas para passwd group e shadow.

passwd:         compat ldap
group:          compat ldap
shadow:         compat ldap 

Verifique se 'sudo getent shadow' está funcionando para entradas do ldap. Verifique se você pode obter uma conexão autenticada usando o ldap-search a partir do ldap-utils usando seus dados de conexão /etc/ldap.conf.

Dependendo da sua configuração, você também terá que configurar os valores de SSL no /etc/ldap.conf.

    
por 17.06.2010 / 21:06
1
  • Primeiramente, você precisará abrir seu gerenciador de pacotes favorito e instalar o libpam-ldap
    • Quando os pacotes começarem a ser descompactados, você receberá algumas perguntas sobre:
      . Endereço IP / nome do host do servidor LDAP
      . A base de pesquisa do seu domínio LDAP, etc ...
    • Agora você precisa personalizar o PAM para que ele use LDAP para autenticação:% sudo vi /etc/pam.d/login
    • você precisa adicionar uma linha acima da linha existente:

auth sufficient pam_ldap.so
auth required pam_unix.so try_first_pass

Ou modificou o arquivo de autenticação comum

    
por 17.06.2010 / 17:33

Tags