魏蓝

以梦为马

导航

pam模块功能和常用模块

一、PAM简单介绍

1.它提供了对所有服务进行认证的中央机制,适用于login,远程登录(telnet,rlogin,fsh,ftp,点对点协议(PPP)),su等应用程序中。系统管理员通过PAM配置文件来制定不同应用程序的不同认证策略;应用程序开发者通过在服务程序中使用PAM API(pam_xxxx( ))来实现对认证方法的调用;而PAM服务模块的开发者则利用PAM SPI来编写模块(主要是引出一些函数pam_sm_xxxx( )供PAM接口库调用),将不同的认证机制加入到系统中;PAM接口库(libpam)则读取配置文件,将应用程序和相应的PAM服务模块联系起来。

 

 2.官网:http://www.linux-pam.org/

 

二、PAM相关文件

1.包名:pam

 

 2.模块文件目录:

/usr/lib64/security/*.so

 

 3.某些模块的配置文件:

/etc/security/

 

 4.每个应用模块对应的配置文件:

/etc/pam.d/

 

 

三、PAM配置文件说明

1.专用配置文件/etc/pam.d/ 格式

type control module-path arguments

四列

 

2. 模块类型(module-type)

  • Auth 账号的认证和授权
  • Account 帐户的有效性,与账号管理相关的非认证类的功能,如:用来限制/允许用户对某个服务 的访问时间,限制用户的位置(例如:root用户只能从控制台登录)
  • Password 用户修改密码时密码复杂度检查机制等功能
  • Session 用户会话期间的控制,如:最多打开的文件数,最多的进程数等
  • -type 表示因为缺失而不能加载的模块将不记录到系统日志,对于那些不总是安装在系统上的模块有用

3.Control:

  • required :一票否决,表示本模块必须返回成功才能通过认证,但是如果该模块返回失败,失败结果也不会立即通知用户,而是要等到同一type中的所有模块全部执行完毕,再将失败结果返回给应用程序,即为必要条件
  • requisite :一票否决,该模块必须返回成功才能通过认证,但是一旦该模块返回失败,将不再执行同一type内的任何模块,而是直接将控制权返回给应用程序。是一个必要条件
  • sufficient :一票通过,表明本模块返回成功则通过身份认证的要求,不必再执行同一type内的其它模块,但如果本模块返回失败可忽略,即为充分条件,优先于前面的required和requisite
  • optional :表明本模块是可选的,它的成功与否不会对身份认证起关键作用,其返回值一般被忽略
  • include: 调用其他的配置文件中定义的配置信息

4.module-path:

  • 模块文件所在绝对路径:
  • 模块文件所在相对路径:/lib64/security目录下的模块可使用相对路径,如:pam_shells.so、pam_limits.so
  • 有些模块有自已的专有配置文件,在/etc/security/*.conf目录下

5.Arguments

  • debug :该模块应当用syslog( )将调试信息写入到系统日志文件中
  • no_warn :表明该模块不应把警告信息发送给应用程序
  • use_first_pass :该模块不能提示用户输入密码,只能从前一个模块得到输入密码
  • try_first_pass :该模块首先用前一个模块从用户得到密码,如果该密码验证不通过,再提示用户输入新密码
  • use_mapped_pass 该模块不能提示用户输入密码,而是使用映射过的密码
  • expose_account 允许该模块显示用户的帐号名等信息,一般只能在安全的环境下使用,因为泄漏用户名会对安全造成一定程度的威胁

四、Pam_shells模块

功能:pam_shells is a PAM module that only allows access to the system if the user's shell is listed in /etc/shells.

 

 

五、pam_securetty.so模块

功能:am_securetty is a PAM module that allows root logins only if the user is logging in on a "secure" tty, as defined by the listing in the securetty file. pam_securetty checks at first, if /etc/securetty exists. If not and it was built with vendordir support, it will use %vendordir%/securetty. pam_securetty also checks that the securetty files are plain files and not world writable. It will also allow root logins on the tty specified with console= switch on the kernel command line and on ttys from the /sys/class/tty/console/active.

 

 centos8默认没有这个文件

 

六、pam_nologin.so 模块

功能:pam_nologin is a PAM module that prevents users from logging into the system when /var/run/nologin or /etc/nologin exists. The contents of the file are displayed to the user. The pam_nologin module has no effect on the root user's ability to log in.

 

 

 

 

写于2022-3-21-17:03

posted on 2022-03-21 17:03  魏蓝  阅读(950)  评论(0编辑  收藏  举报