关于 nscd,nslcd 和 sssd 套件的综述

2024-01-03 18:58
文章标签 综述 套件 sssd nscd nslcd

本文主要是介绍关于 nscd,nslcd 和 sssd 套件的综述,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


关于 nscd,nslcd 和 sssd 套件的综述

旧式libnss_ldap和pam_ldap的库文件:
/lib/x86_64-linux-gnu/libnss_ldap-2.13.so
/lib/x86_64-linux-gnu/security/pam_ldap.so

新式libnss_ldapd和libpam_ldapd(即nslcd)的库文件:
/lib/x86_64-linux-gnu/libnss_ldap.so.2
/lib/x86_64-linux-gnu/security/pam_ldap.so

套件sssd自带的libnss_sss和pam_sss库文件:
/lib/libnss_sss.so.2
/lib/security/pam_sss.so


********************************************************************************
注意:不要混淆了 nscd 和 nslcd(local LDAP name service daemon)两个完全不同的服务
********************************************************************************
nslcd(即nss-pam-ldapd)本身包括了一个瘦身版本的 PAM 模块和一个瘦身版本的 NSS 模块,
但您依然可以单独构建这三个部分(NSS 模块,PAM 模块和 nslcd server),这意味着您
依然还可以使用 pam_ldap 套件和使用来自 nss-pam-slapd 套件的NSS模块,但目前此套件
不能与nss_ldap套件在同一个系统中同时并行使用。

nslcd 套件的正式名称是 Daemon for NSS and PAM lookups using LDAP(nss-pam-ldapd),
它最初由PADL软件公司的Luke Howard开发,作为 nss_ldap 的分支,名为 nss-ldapd 套件。
2006年,West Consulting 的  Arthur de Jong 将这个库分成 NSS 部分和 server 部分并
重写了大部分代码。当 OpenLDAP 的 nssov 模块的 Howard Chu 贡献出 PAM 代码时,这个
软件被重新命名为 nss-pam-ldapd 套件。但在 RedHat 和 Debian 中此套件有不同的名称:

CentOS:  nss-pam-ldapd  - An nsswitch module which uses directory servers
Ubuntu:  nslcd  - Daemon for NSS and PAM lookups using LDAP

nslcd自带pam模块,因此完全不需要配置/etc/pam.d/目录下的服务,它不用ldap.conf配置
文件,而使用自己的配置文件/etc/nslcd.conf配置LDAP的访问参数。而且,nslcd.conf 的
预设map可以正常使用(即用RFC2307预设标准:ou=people对应用户, ou=Groups对应群组),
因此,您无需在/etc/nslcd.conf文档中手工配置nss_base_passwd和nss_base_group等映射,
除非您的LDAP数据库本身使用了非RFC2307标准的用户结构。

因此,要使用 nslcd 服务,还需要针对LDAP服务器进行配置, 使用 authconfig-tui 命令
也会自动配置 nslcd 的配置文件(/etc/nslcd.conf)。而 nscd 只有通用的缓存定义的配置,
一般情况下无需调整其配置文件(/etc/nscd.conf)。

注意,nslcd 并没有缓存的功能,它是专门为本地处理有关 LDAP 名称服务查询的后台进程,
查询结果依然由 nscd 缓存。(This package provides a daemon for retrieving user
account, and other system information from LDAP. It is used by the libnss-ldapd
and libpam-ldapd packages but by itself is not very useful)。

man nscd;
--------------------------------------------------------------------------------
/usr/sbin/nscd - name service cache daemon

Nscd is a daemon that provides a cache for the most common name service requests.
Default configuration /etc/nscd.conf determines the behavior of the cache daemon.

Nscd provides caching for: passwd, group, hosts databases through standard libc
interfaces (getpwnam, getpwuid, getgrnam, getgrgid, gethostbyname, and others).

There are two caches for each database:
  * a positive one for items found, and
  * a negative one for items not found. 

Each cache has a separate TTL (time-to-live) period for its data.
Note that the shadow file is specifically not cached.
--------------------------------------------------------------------------------

因此,您可以停止 nscd 进程,这样相关查询会自动绕过缓存,直接向相关的名称服务递交
查询请求(例如关于LDAP的查询请求则会直接查询nslcd后端进程)。 但是,如果您停止了
nslcd后台进程,如果相关记录的TTL又已经到期了,那么查询就会返回错误的结果。在默认
的设置下,密码的 positive-time-to-live 设为600秒,negative-time-to-live则为20秒。

如果修改了/etc/nsswitch.conf文件,相关影响会稍为延后才起作用,但您可以用如下命令
令nscd后台进程立即无效化其缓存记录,例如: nscd -i passwd;  您也可以直接删除缓存

/var/cache/nscd(或/var/db/nscd) 目录下的数据库文件,然后重启nscd后台守护进程即可。

 




────────────────────────────────────────────────────────────────────────────────
注意:sssd 与 nscd 的冲突
────────────────────────────────────────────────────────────────────────────────
另外请留意,新版RedHat/CentOS默认改为使用SSSD来处理有关系统安全服务的名称查询请求,
因为sssd服务本身已经具备缓存的功能,因此可以不使用nscd后台进程(重复缓存并无好处)。
如果同时启动nscd服务,那么sssd启动时会提示警告信息如下:

  Starting sssd: nscd socket was detected.  As nscd caching capabilities may
  conflict with SSSD, it is recommended to not run nscd in parallel with SSSD
或者在 /var/log/messages 日志中显示如下信息:
  sssd: nscd socket was detected. Nscd caching capabilities may conflict with SSSD
  for users and groups. It is recommended not to run nscd in parallel with SSSD,
  unless nscd is configured not to cache the passwd, group and netgroup nsswitch maps.

在sssd.conf的说明中,默认的 entry_cache_timeout=5400(秒),但是,在CentOS中默认
安装下所配置的sssd服务并没有启用记录条目的缓存功能(设成entry_cache_timeout = 0)。
Password caching for offline supporting by specifying "cache_credentials = True"
in sssd.conf. If config file uses that option, offline logins should just work.
RedHat官方建议关闭nscd服务进程,但在实用中发现 sssd 实在是问题多多,或许还是按照
如下RedHat官方网站文档中的指示让这两个服务共存为好!


********************************************************************************
如下是RedHat官方的正式解释:
********************************************************************************
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/usingnscd-sssd.html

10.2.9. Using NSCD with SSSD
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
SSSD is not designed to be used with the NSCD daemon. Even though SSSD does not
directly conflict with NSCD, using both services can result in unexpected behavior,
especially with how long entries are cached.

The most common evidence of a problem is conflicts with NFS. When using Network
Manager to manage network connections,   it may  take  several  minutes for the
network interface to come up. During this time, various services attempt to start.

If these services start before the network is up and the DNS servers are available,
these services will fail to identify the forward or reverse DNS entries they need.
These services will read an incorrect or possibly empty  /etc/resolv.conf  file.
This file is typically only read once, and so any changes made to this file are
not automatically applied.  This can cause NFS locking to fail on the machine
where the NSCD service is running, unless that service is manually restarted.

To avoid this problem, enable caching for hosts and services in the /etc/nscd.conf
file and rely on the SSSD cache for the passwd, group, and netgroup entries.

Change the /etc/nscd.conf file:
enable-cache hosts yes
enable-cache passwd no
enable-cache group no
enable-cache netgroup no

With NSCD answering hosts requests, these entries will be cached by NSCD and
returned by NSCD during the boot process. All other entries are handled by SSSD.


注意:事实上nscd目前只支持缓存四种名称服务: passwd, group, hosts, services,而且
新版的nscd配置文件有点古怪的地方,如果您想注释一行,您一定必须将 “#” 添加在最前面
一列,而不能在前面带任何空格或tab分栏,否则重启nscd服务会遇到failed to start问题。

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



────────────────────────────────────────────────────────────────────────────────
如何查看当前系统的身份认证配置模式?
────────────────────────────────────────────────────────────────────────────────
在RedHat系统中可以使用authconfig命令查看当前的认证模式配置,例如:
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
authconfig --test | egrep -i 'ldap|sss'
authconfig --test | egrep -i 'ldap|sss|pam|nss'
--------------------------------------------------------------------------------
nss_files is always enabled
nss_compat is disabled
nss_db is disabled
nss_hesiod is disabled
nss_ldap is disabled
 LDAP+TLS is disabled
 LDAP server = "ldap://192.168.56.1/"
 LDAP base DN = "dc=hung,dc=moon,dc=com"
nss_nis is disabled
nss_nisplus is disabled
nss_winbind is disabled
nss_sss is enabled by default
nss_wins is disabled
DNS preference over NSS or WINS is disabled
pam_unix is always enabled
pam_krb5 is disabled
pam_ldap is disabled
 LDAP+TLS is disabled
 LDAP server = "ldap://192.168.56.1/"
 LDAP base DN = "dc=hung,dc=moon,dc=com"
 LDAP schema = "rfc2307"
pam_pkcs11 is disabled
pam_fprintd is enabled
pam_smb_auth is disabled
pam_winbind is disabled
pam_sss is enabled by default
 credential caching in SSSD is enabled
 SSSD use instead of legacy services if possible is enabled
pam_cracklib is enabled (try_first_pass retry=3 type=)
pam_passwdqc is disabled ()
pam_access is disabled ()
pam_mkhomedir or pam_oddjob_mkhomedir is disabled ()
--------------------------------------------------------------------------------


在Debian/Ubuntu系统中则可使用auth-client-config工具查看当前的NSS和PAM配置,例如:
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
auth-client-config -S
--------------------------------------------------------------------------------
nss_group=group:          compat
nss_netgroup=netgroup:       nis
nss_passwd=passwd:         compat
nss_shadow=shadow:         compat
pam_account=account [success=2 new_authtok_reqd=done default=ignore] pam_unix.so 
account [success=1 default=ignore] pam_ldap.so 
account requisite pam_deny.so
account required pam_permit.so
pam_auth=auth [success=2 default=ignore] pam_unix.so nullok_secure
auth [success=1 default=ignore] pam_ldap.so use_first_pass
auth requisite pam_deny.so
auth required pam_permit.so
auth optional pam_cap.so
pam_password=password requisite pam_cracklib.so retry=3 minlen=8 difok=3
password [success=2 default=ignore] pam_unix.so obscure use_authtok try_first_pass sha512
password [success=1 user_unknown=ignore default=die] pam_ldap.so use_authtok try_first_pass
password requisite pam_deny.so
password required pam_permit.so
password optional pam_gnome_keyring.so
pam_session=session [default=1] pam_permit.so
session requisite pam_deny.so
session required pam_permit.so
session optional pam_umask.so
session required pam_unix.so 
session optional pam_ldap.so 
session optional pam_ck_connector.so nox11
--------------------------------------------------------------------------------

这篇关于关于 nscd,nslcd 和 sssd 套件的综述的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/566733

相关文章

安卓开发板_联发科MTK开发评估套件串口调试

串口调试 如果正在进行lk(little kernel ) 或内核开发,USB 串口适配器( USB 转串口 TTL 适配器的简称)对于检查系统启动日志非常有用,特别是在没有图形桌面显示的情况下。 1.选购适配器 常用的许多 USB 转串口的适配器,按芯片来分,有以下几种: CH340PL2303CP2104FT232 一般来说,采用 CH340 芯片的适配器,性能比较稳定,价

kaggle竞赛宝典 | Mamba模型综述!

本文来源公众号“kaggle竞赛宝典”,仅用于学术分享,侵权删,干货满满。 原文链接:Mamba模型综述! 型语言模型(LLMs),成为深度学习的基石。尽管取得了令人瞩目的成就,Transformers仍面临固有的局限性,尤其是在推理时,由于注意力计算的平方复杂度,导致推理过程耗时较长。 最近,一种名为Mamba的新型架构应运而生,其灵感源自经典的状态空间模型,成为构建基础模型的有力替代方案

AI文献综述神器,有这一款就够了!

我是娜姐 @迪娜学姐 ,一个SCI医学期刊编辑,探索用AI工具提效论文写作和发表。 当前的AI辅助文献综述的工具有很多,如果说功能最强大的,娜姐无疑要推SciSpace了。 SciSpace利用强大的AI算法,理解并建立研究论文之间的联系,可以大大提升文献综述的质量和效率。并且其功能还在不断更新和完善。        1 强大的语义搜索功能 传统的关键词搜索可能会遗漏相关文献,Sc

20180108文献综述书写感悟

在写文献综述理清各章节脉络的时候,发现了以下几个问题,共勉之。 1、资源对接问题:章节应该明确标注出处,来源,例如(from 百度/某篇文章链接),不写,则默认为原创。 以方便下一个接着写的同学清晰了解资料来源。 2、质量低:上任对发展史做了整理,但并没有输出成原创性文字,重新阅读加大理解成本,并且思路不新不全局不清晰,需要重新绘之。

Netty源码解析4-Handler综述

Netty中的Handler简介 Handler在Netty中,占据着非常重要的地位。Handler与Servlet中的filter很像,通过Handler可以完成通讯报文的解码编码、拦截指定的报文、 统一对日志错误进行处理、统一对请求进行计数、控制Handler执行与否。一句话,没有它做不到的只有你想不到的 Netty中的所有handler都实现自ChannelHandler接口。按照输入

如何快速写文献综述

真实参考文献的AI论文生成器:AIPaperDone - AI 万字论文生成 在本文中,你将学习如何为不同的学术领域撰写文献综述。 请注意: 文献综述并不是关于小说或诗歌等文学作品的。当我们说"文献",我们指的是某个领域的"研究"。撰写文献综述意味着收集你主题的关键资料,对它们进行概述,并分析它们之间的关系。 以下是如何快速完成的方法。 什么是文献综述? 文献综述是一篇学术论

零样本学习(zero-shot learning)——综述

-------本文内容来自对论文A Survey of Zero-Shot Learning: Settings, Methods, and Applications 的理解和整理,这里省去了众多的数学符号,以比较通俗的语言对零样本学习做一个简单的入门介绍,用词上可能缺乏一定的严谨性。一些图和公式直接来自于论文,并且省略了论文中讲的比较细的东西,如果感兴趣建议还是去通读论文 注1:为了方便,文中

卷积神经网络综述

摘要 本文对卷积神经网络(Convolutional Neural Network,CNN)进行了全面综述。首先介绍了卷积神经网络的发展历程,包括早期的理论基础和关键突破。接着详细阐述了卷积神经网络的结构组成,包括卷积层、池化层、全连接层等,分析了各层的作用和特点。然后探讨了卷积神经网络在图像识别、目标检测、语义分割等多个领域的应用,并介绍了一些典型的应用案例。此外,还讨论了卷积神经网络的训练方

复旦大学王龑团队发布《静态与动态情感的面部表情识别》综述

论文链接:https://arxiv.org/pdf/2408.15777 复旦大学,王龑博士后领衔,发布《静态与动态情感的面部表情识别》(A Survey on Facial Expression Recognition of Static and Dynamic Emotions)综述,对基于图像的静态面部表情识别(SFER)和基于视频的动态面部表情识别(DFER)方法进行了全面综述,从

【论文阅读】语义通信安全研究综述(2024)

摘要 语义通信系统架构 笔记 内容概述 引言:介绍了语义通信技术的背景、发展和重要性,以及它在无线通信系统中面临的安全挑战。 语义通信系统架构及安全攻击:描述了一个端到端的深度学习语义通信系统的基本架构,包括语义编解码器、信道编解码器和收发端知识库等模块,并讨论了这些模块可能遇到的安全攻击,如窃听、篡改等。 语义通信模型安全研究现状:详细讨论了模型安全攻击手段(数据投毒、后门