[Linux]sssd实现登录验证以及对应用户home directory的overwrite

[Linux]sssd实现登录验证以及对应用户home directory的overwrite

起因是用户想更改用sssd登录用户的home directory的路径,解决了的同时就想顺便梳理一下相关知识,特此记录。

sssd实现登录验证

sssd是Linux6起加入的一个守护进程,可以用来访问多种验证服务器,比方LDAP, Kerberos等,并提供授权。它是介于本地用户和数据存储之间的进程,本地客户端首先连接SSSD, 再由SSSD联系外部资源提供者。

这样做的优势:

  1. 避免每个本地应用都对认证服务器大量连接。所有本地程序仅联系SSSD,由SSSD连接认证服务器或SSSD缓存,有效的降低了负载。
  2. 允许离线授权。SSSD可以缓存远程服务器的用户认证身份,这允许在远程认证服务器宕机时,继续成功授权用户访问必要的资源。

SSSD不在local system生成用户账户,而是从远程服务器获取身份信息。它同时也为一些system services提供缓存,比如Name Service Switch (NSS) 或 Pluggable Authentication Modules (PAM)。
sssd_how-1

SSSD默认配置文件:/etc/sssd/sssd.conf, 你可以通过命令使得SSSD以指定的配置文件运行:

sssd --c /etc/sssd/customfile.conf

除此之外SSSD也可以以字母顺序读取/etc/sssd/conf.d/文件夹下所有的*.conf文件。

配置SSSD的Identity and Authentication Providers

Identity and authentication providers are configured as domains in the SSSD configuration file. A single domain can be used as:

  • An identity provider (for user information)
  • An authentication provider (for authentication requests)
  • An access control provider (for authorization requests)
  • A combination of these providers (if all the corresponding operations are performed within a single server)
    你可以为SSSD设置多个domain, 至少需要一个,不然SSSD不会启动。

为SSSD配置一个LDAP Domain

这一段可以参考RHEL的官方文档
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system-level_authentication_guide/configuring_domains
实际上看起来大约是:
WX20200915-190556@2x

Home directory overwrite

做法是在sssd.conf里把如下entries从[sssd] section移动至[domain/lab.local]

override_homedir = /home/%u
default_shell = /bin/bash

然后重启服务

service sssd stop
service sssd start

References:
http://www.361way.com/redhat-sssd/4770.html
https://blog.csdn.net/liu16659/article/details/80997333
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/ch-configuring_authentication
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system-level_authentication_guide/sssd
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system-level_authentication_guide/configuring_domains
https://qastack.cn/unix/334287/pam-vs-ldap-vs-sssd-vs-kerberos
https://serverfault.com/questions/676284/home-dir-and-shell-for-active-directory-authenticated-users
https://www.thegeekdiary.com/understanding-system-security-services-daemon-sssd/
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/configuring_services

Subscribe to 隅

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe