歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> Linux文化 >> 使用PAM進行統一身份的認證(續)

使用PAM進行統一身份的認證(續)

日期:2017/2/27 12:19:38   编辑:Linux文化

模塊導引, 這裡對最常用的10個模塊做了描述.
想知道更多的信息, 你可以察看/usr/doc/pam* 下的文件.

1) Chroot
pam_chroot

Management groups provided:
account; session; authentication

為用戶提供了一偽造的文件系統.

2) Cracklib pluggable password strength-checker
pam_cracklib

Management groups provided:
password

需要庫libcrack 和議本系統字典/usr/lib/cracklib_dict.
檢查密碼的可靠性
對下列問題進行檢查:
Palindrome - 回文 速度和倒讀都一樣
Case Change Only - 僅僅是大小寫的變化
Similar - 過於相似
Simple - 太簡單了
Rotated - 是舊密碼的循環

Password component

可識別的參數
debug; type=XXX; retry=N; difok=N; minlen=N; dcredit=N;
ucredit=N; lcredit=N; ocredit=N;

Description:
提示用戶輸入密碼,並檢查密碼是否可靠.

debug - 透過syslogd來寫信息.
type=XXX - 系統的名字
retry=N - 可重試的次數
difok=N - 至少要有多少個字符不同
minlen=N - 新密碼的長度加一的最小值
dcredit=N ucredit=N lcredit=N ocredit=N -
最少要有多少的數字,大寫字母,小寫字母和其它字母.

3) Deny
pam_deny

Management groups provided:
account; authentication; password; session

用於拒絕提供服務.

Account component
僅僅是返回一個錯誤 PAM_ACCT_EXPIRED.

#
# add this line to your other login entries to disable all accounts
#
login account required pam_deny.so

Authentication component
僅僅是返回一個錯誤 PAM_AUTH_ERR. 當調用 pam_authenticate()時.
返回 PAM_CRED_UNAVAIL, 當調用 pam_setcred() 時.

#
# add this line to your existing OTHER entries to prevent
# authentication succeeding with default applications.
#
OTHER auth required pam_deny.so

Password component

Recognized arguments:
Description:
拒絕用戶修改密碼.返回PAM_AUTHTOK_ERR.

Examples/suggested usage:

#
# add this line to your other login entries to prevent the login
# application from being able to change the user's password.
#
login password required pam_deny.so

Session component

阻止用戶在主機上開始一個session.

Examples/suggested usage:
#
# An example to see how to configure login to refuse the user a
# session (politely)
#
login session required pam_motd.so file=/etc/system_time
login session required pam_deny.so

4) Anonymous access module
pam_ftp.so

Management groups provided:
authentication

Overview of module

提供了匿名ftp認證.

Authentication component
參數:
debug; users=XXX,YYY,...; ignore

丹用戶名為ftp或anonymous時,將密碼安@分為 PAM_RUSER 和 PAM_RHOST;
相應的設置pam-items. 用戶名被設為 ftp.

debug - syslog
users=XXX,YYY,...- 允許的用戶名.
ignore - 不關心用戶的email地址.

The group access module
pam_group

Management groups provided:
authentication

System dependencies:
需要設置 /etc/security/group.conf

Network aware:
需要正確設置PAM_TTY item.

Overview of module
基於用戶名和它們使用的終端來決定是否提供服務.

Authentication component


5) The last login module
pam_lastlog

Management groups provided:
auth

System dependencies:
所用的信息包含在/var/log/wtmp中.

Overview of module

這個模塊維護 /var/log/wtmp . 增加打開的一項當調用 pam_open_seesion()
當pam_close_session()時關閉該項.它也顯示一條信息表示用戶上次何時登陸.
``Last login on ...'' 該模塊維護 /var/log/wtmp.

Authentication component

Recognized arguments:

debug; nodate; noterm; nohost; silent; never

Description:

debug - write more information to syslog(3).
nodate - 不顯示上次登陸的時間
noterm - 不顯示上次登陸的終端.
nohost - 不顯示上次登陸的主機.
silent - 不顯示上次登陸的信息,值更新 /var/log/wtmp.
never - 如果/var/log/wtmp 不包含上次登陸的信息. 顯示``welcome..."

Examples/suggested usage:
這個木塊可以用來顯示該用戶收到了new mail,當它們登陸到系統中時.

#
# do we have any mail?
#
login session optional pam_lastlog.so


6) The resource limits module
pam_limits

Management groups provided:
session

/etc/security/limits.conf內核支持 resource limits.

Overview of module

通過 Linux-PAM open-session hook 設置用戶的session可使用的系統資源上限

Session component

Recognized arguments:

debug; conf=/path/to/file.conf

root不受限制
conf=/path/to/file.conf 指定替代缺省的配置文件的文件名

例如:
為了使用這個模塊 /etc/security/limits.conf 必須是root只讀的


The fields listed above should be filled as follows...
可以是用戶名,用戶組名(@group) 或統配符 * 表示缺省規則
可以是 hard soft
hard 強制實行 由管理員設置 由Linux Kernel執行 . 用戶無權改變.
soft 非強制執行. 用戶可以改變 在之前存在的 hard limits 允許下.
可以是下列值:
core - core 文件的大小 (KB)
data - 最大的data大小 (KB)
fsize - maximum filesize (KB)
memlock - max locked-in-memory address space (KB)
nofile - max number of open files
rss - max resident set size (KB)
stack - max stack size (KB)
cpu - max CPU time (MIN)
nproc - max number of processes
as - address space limit
maxlogins - max number of logins for this user.

通過加一個(-)來完全取消限制 (Example: ``bin -'', ``@admin -'').
注意用戶的優先級比組的優先級要高.

下面是一個例子:
# EXAMPLE /etc/security/limits.conf file:
# =======================================
#
* soft core 0
* hard rss 10000
@student hard nproc 20
@faculty soft nproc 20
@faculty hard nproc 50
ftp hard nproc 0
@student - maxlogins 4


7) The no-login module
pam_nologin

Management groups provided:

authentication

Overview of module

提供了標准的unix nologin服務.

Authentication component

Recognized arguments:
Description:
當/etc/nologin文件存在時就拒絕login.


8) The Password-Database module
pam_pwdb

Management groups provided:

account; authentication; password; session

Overview of module

用於取代 pam_unix_* 模塊. 它使用了通用的 Password Database
library 接口函數.

Account component

Recognized arguments:

debug

例如:
/etc/pam.d/login 一定會有下面一行.
#
# Ensure users account and password are still active
#
login account required pam_pwdb.so

Authentication component

可用的闡述:
debug; use_first_pass; try_first_pass; nullok; nodelay

debug就沒什麼好說的了.
use_first_pass try_first_pass 在我的另一篇文章中已經所得很清楚了.
nullok時所允許空密碼登陸.
nodelay在失敗後不停留. 這一延時是為了抵擋基於字典的暴力入侵.

Password component

Recognized arguments:
debug; nullok; not_set_pass; use_authtok; try_first_pass;
use_first_pass; md5; bigcrypt; shadow; radius; unix

Description:

not_set_pass 不為棧中的其它模塊保留密碼.
md5是所用MD5算法來代替標准的算法.
bigcrypt是指處理長度超過8個字符的密碼.
unix使用標准的加密方式.
shadow使用shadow文件.
radius:使用遠程撥入用戶服務器.

Session component

它只是通過 syslog(3) 來紀錄一下.
例如:
#
# pwdb - unix like session opening and closing
#
login session required pam_pwdb.so

9) The rhosts module
pam_rhosts_auth

Management groups provided:
authentication

對使用 rlogin 和 rsh 進行安全性檢查.

Authentication component
可用參數:

no_hosts_equiv; no_rhosts; debug;
no_warn; privategroup; promiscuous; suppress

Description:

它通過 /etc/hosts.equiv 和 ~/.rhosts 來確認.

no_hosts_equiv 忽略 /etc/hosts.equiv 的內容.
no_rhosts 忽略 ~/.rhosts的內容.
privategroup 通常~/.rhost必須只有宿主才能寫否則就失敗. 這一選項
是同組可寫的 ~/.rhosts 也被使用.
promiscuous 不使用這一選項 配置文件中的 '+' 項 將被忽略.
suppress 禁止模塊用 syslog(3) 來發警告信息.


10) The securetty module
pam_securetty

Management groups provided:

authentication

Overview of module
提供了標准的安全終端的檢查(使用/etc/securitty)


- Bricks Team


Copyright © Linux教程網 All Rights Reserved