AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1005225
Accepted
Ingo
Ingo
Asked: 2020-03-02 16:18:26 +0800 CST2020-03-02 16:18:26 +0800 CST 2020-03-02 16:18:26 +0800 CST

通过 Kerberos SASL/GSSAPI 对 OpenLDAP 服务器使用 SSSD 进行单点登录

  • 772

针对 Kerberos 的身份验证和针对 LDAP 目录的授权对我有用。现在我正在使用sssd在 Debian Buster 上寻找客户端设置。

我开始使用nss-pam-ldapd 进行 LDAP 身份验证,在 OpenLDAP 服务器上使用SASL 代理授权,并使用ccreds缓存 OpenLDAP 凭据。但是因为我一直使用systemd及其环境,传统的设置不太适合它,我遇到了一些问题OpenLDAP 服务器。

正因为如此,我查看了sssd,发现它可以一体完成,而且它基于systemd并且还使用dbus进程间通信。所以我决定改用它。但在 Debian 上,推荐的软件包sssd会安装所有可能的服务,例如用于活动目录和其他我不需要的东西。我想让我的客户在没有未使用的软件的情况下尽可能精简,所以我的问题是:

我必须安装哪些 Debian 软件包才能使用sssd对具有 Kerberos SASL/GSSAPI 的 OpenLDAP 服务器进行单点登录,以及如何配置它?

openldap debian-buster sssd mitkerberos gssapi
  • 1 1 个回答
  • 1734 Views

1 个回答

  • Voted
  1. Best Answer
    Ingo
    2020-03-02T16:18:26+08:002020-03-02T16:18:26+08:00

    抽象的

    经过一些尝试和错误后,我发现我需要一个用于 gssapi 的包和四个用于 sssd 的包。我想集中通用配置,因此我使用本地私有 dns 服务器进行名称、服务器名称和服务名称解析。所以首先我在客户端上检查这个。如果您在 DNS 服务器上没有它,您可以在每个客户端上将其全部定义为本地。我已经评论过了。为了避免安装不需要的附加软件包,我总是为 Debian **apt** 使用选项 `--no-install-recommends`。

    准备 Kerberos 客户端

    首先确保你有一个有效的 `/etc/krb5.keytab` 和 `sudo klist -ke`。如果不可用,则创建一个:
    rpi ~$ sudo kadmin -p user/admin
    kadmin:  addprinc -policy host -randkey host/<hostname>.example.com
    kadmin:  ktadd host/<hostname>.example.com
    kadmin:  q
    

    在安装了 GNOME 或 Xfce 等图形用户界面后,我遇到了名称解析问题。sssd无法example.com使用我的扩展 DNS 名称解析来解析 DNS 域,因此它找不到 Kerberos 和 LDAP 服务器,并且登录失败并显示错误消息Authentication failure。这有时可能会起作用,因为缓存的登录数据但无效的 kerberos 票证数据1970-01-01显示为klist. 根据Debian 主机名解析,您应该有这样的条目/etc/hosts:

    127.0.1.1    <hostname>.example.com    <hostname>
    

    如果您为名称服务运行nscd缓存,请卸载它。我们不能使用它,因为sssd也会这样做。

    ~$ sudo systemctl disable --now nscd.service
    ~$ sudo apt purge nscd
    ~$ sudo apt-mark hold nscd
    

    安装针对 Kerberos 和测试进行身份验证所需的 SASL/GSSAPI 模块和帮助程序:

    ~$ sudo apt --no-install-recommends install libsasl2-modules-gssapi-mit dnsutils ldap-utils
    
    # check DNS resolution; must resolve full qualified dns names
    ~$ dig +noall +answer $(hostname -f)
    ~$ dig +noall +answer -x $(hostname -I)
    
    # Check Kerberos server and LDAP server
    ~$ dig +noall +answer ldap-primary.example.com
    ~$ dig +noall +answer kdc-master.example.com
    
    # Query for kerberos service (response: kdc10-1.example.com on port 88)
    ~$ dig +noall +answer SRV _kerberos._udp.example.com
    _kerberos._udp.example.com 38400 IN SRV   0 0 88 kdc10-1.example.com.
    # Query for ldap service (response: kdc10-1.example.com on port 389)
    ~$ dig +noall +answer SRV _ldap._tcp.example.com
    _ldap._tcp.example.com. 38400 IN SRV   0 0 389 kdc10-1.example.com.
    
    # Check if the sssd.service can access the LDAP-server. It uses this principal
    ~$ sudo kinit -k host/<hostname>.example.com
    ~$ sudo ldapsearch -Y GSSAPI -LLL -H ldap://ldap-primary.example.com -b "ou=home,dc=example,dc=com" "(cn=ingo)" uid cn
    SASL/GSSAPI authentication started
    SASL username: host/<hostname>[email protected]
    SASL SSF: 256
    SASL data security layer installed.
    dn: cn=ingo,ou=group,ou=home,dc=example,dc=com
    cn: ingo
    
    dn: uid=ingo,ou=people,ou=home,dc=example,dc=com
    uid: ingo
    cn: Ingo
    

    安装sssd


    我们只需要四个包就可以为 ldap、krb5、name service 和 pam 提供所有需要的服务:

    ~$ sudo apt --no-install-recommends install sssd-ldap sssd-krb5 libnss-sss libpam-sss
    

    唯一剩下的就是配置/etc/sssd/sssd.conf. 我用这个:

    ~$ sudo cat /etc/sssd/sssd.conf
    [sssd]
    # debug log files in /var/log/sssd/
    #debug_level = 7
    config_file_version = 2
    domains = HOME
    # don't set services on Debian Bullseye. It's managed there
    # by sssd-nss.socket and sssd-pam-priv.socket
    services = nss, pam
    
    [nss]
    #debug_level = 7
    
    [pam]
    #debug_level = 7
    
    [domain/HOME]
    #debug_level = 7
    # Set enumerate only for debugging, never for production!
    #enumerate = TRUE
    
    id_provider = ldap
    # If you haven't a SRV record in DNS for the server then set it here
    #ldap_uri = ldap://ldap-primary.example.com
    # SRV record for backup server isn't supported. We have to set it always.
    ldap_backup_uri = ldap://ldap-secondary.example.com
    ldap_search_base = ou=home,dc=example,dc=com
    ldap_sasl_mech = gssapi
    
    auth_provider = krb5
    chpass_provider = krb5
    # Maybe I want to use the .k5login file in the home directory of the user
    access_provider = krb5
    
    # If you haven't a SRV record in DNS for the server then set it here
    #krb5_server = kdc-master.example.com
    # SRV record for backup server isn't supported. We have to set it always.
    krb5_backup_server = kdc-replica.example.com
    # If the authid isn't the first entry in /etc/krb5.keytab then set it here
    #ldap_sasl_authid = host/<hostname>[email protected]
    # krb5_realm must always be set here. There is no look at `/etc/krb5.conf`
    krb5_realm = EXAMPLE.COM
    #krb5_renewable_lifetime = 3d
    krb5_renew_interval = 1h
    
    # I don't use this
    sudo_provider = none
    autofs_provider = none
    
    cache_credentials = TRUE
    

    不要忘记保护 sssd.conf,否则 sssd 将无法启动:

    ~$ sudo chmod 600 /etc/sssd/sssd.conf
    ~$ sudo systemctl restart sssd.service
    

    检查操作系统是否从 ldap 目录中获取帐户信息。确保查询到的用户帐号只在 ldap 目录中,不在本地文件中。查询的来源由用户 ID 后面的字符指示。

    :x:   from local files (/etc/passwd and /etc/group)
    :*:   from the ldap directory
    

    确保你得到:*:.

    ~$ getent passwd ingo
    ingo:*:1000:1000:Ingo:/home/ingo:/bin/bash
    ~$ getent group ingo
    ingo:*:1000:
    

    为登录设置 pam 身份验证:

    ~$ sudo pam-auth-update
    [*] Unix authentication
    [*] SSS authentication
    [*] Register user sessions in the systemd control group hierarchy
    [*] Create home directory on login
    

    并使用新用户检查登录:

    ~$ ~$ su -l ingo
    Password:
    Creating directory '/home/ingo'.
    ingo:~$ klist
    ingo:~$ logout
    ~$
    

    要测试 sssd.conf 中的设置,您必须知道 sssd 正在缓存许多数据,因此更改不会立即生效。这非常令人困惑。所以我在/var/lib/sss/db/修改 sssd.conf 后删除了带有缓存信息的文件。我用这个单线作为根:

    ~# systemctl stop sssd.service && rm /var/lib/sss/db/* && systemctl start sssd.service
    
    • 1

相关问题

  • OpenLDAP 无效凭证

  • 从 OpenLDAP 检索操作属性

  • 为 Mac 网络使用 Linux 和 Open LDAP

  • 使用LDAP服务器身份验证的Linux中单个用户的多个登录名

  • 将 OpenLDAP 实现为目录而不是控制网络访问的指南?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve