PAM认证模块
通过ldd查看服务程序在编译时是否使用了libpam.so,决定服务程序是否支持PAM 认证 。具体的pam文件放在/lib/security目录下,服务文件放在/etc/pam.d目录下 Pluggable Authentication Modules for Linux 可插拨 认证 模块 当用户访问服务器,服务程序将请求
Pluggable Authentication Modules for Linux 可插拨认证模块
当用户访问服务器,服务程序将请求发送到PAM模块,PAM模块根据服务名称在/etc/pam.d目录下选择一个对应的服务文件,最后根据服务文件的内容选择具体的PAM模块进行处理。
通过ldd查看服务程序在编译时是否使用了libpam.so,决定服务程序是否支持PAM认证。
具体的pam文件放在/lib/security目录下,服务文件放在/etc/pam.d目录下
PAM服务文件格式
eg:
auth required pam_security.so
auth required pam_stack.so service=system-auth
service表示调用子服务文件
Module-type:
auth 检查用户和密码,分配权限
account 检查账号是否过期,是否有权登录
session 从用户登录成功到退出的会话控制
password 控制用户改密码的过程
control-flag:
required 要求矣须通过,否则结束退出
requisite 如果不通过还可继续向下认证,后面有一通过即可。
sufficient 通过则不需要向下认证
optional 可选项
常用PAM服务文件
login -------/etc/pam.d/login
ipop3d -------/etc/pam.d/pop
vsftpd -------/etc/pam.d/ftp(编译安装)或/etc/pam.d/vsftpd(rpm安装)
sshd -------/etc/pam.d/sshd
su -------/etc/pam.d/su
imap -------/etc/pam.d/imap
/lib/security目录下,各个pam模块的作用,可参考/usr/share/doc/pam-0.99.3.0下的帮助文件。
相同类型Module-type组成一个堆栈。
常用PAM模块
pam_access.so 控制访问者地址与账号名称
pam_listfile.so 控制访问者的账号名称或登录位置
pam_limits.so 控制为用户分配的资源
pam_rootok.so 对管理员(uid=0)无条件允许通过
pam_userdb.so 设定独立用户账号数据库认证
pam_access.so模块的使用―――控制访问sshd服务的主机和用户
1.修改需使用这个模块的服务文件,如sshd: /etc/pam.d/sshd添加
account required pam_access.so
2.修改模块的配置文件
/etc/security/access.conf
- : redhat : ALL EXCEPT 192.168.0. (格式)
3.测试
ssh redhat@192.168.0.22
ssh redhat@127.0.0.1
pam_access.so根据主机、IP、用户、拒绝或允许访问。
pam_listfile.so的应用 (比pam_access.so更加详细控制)
1.首先查看它的帮助文件,看它的具体格式,参数如何
#less /usr/share/doc/pam-0.99.3.0/txts/README.pam_listfile
item user,tty,group 说明列表文件中的内容
sense allow,deny 拒绝或允许文件中的用户
file 指定一个文件,内容根据item项来添加
onerr succeed,fail 当模块本身产生错误时,返回的值,如无法打开file指定的文件,一般设为succeed
2.将模块应用到sshd服务
将上面添加的pam_access.so清掉,然后在/etc/pam.d/sshd中添加(第一行)
auth required pam_listfile.so item=user sense=deny file=/etc/denyuser onerr=succeed
注意添加的位置顺序,否则看不到效果
3.创建编缉列表文件
#echo “redhat” >/etc/denyuser
4.测试
#ssh -l redhat 192.168.0.22 失败
#ssh -l chinaitlab 192.168.0.22 成功
#w 显示已登录的用户及最近的一次操作
pam_limits.so的应用
1.查看帮助文件,确认它的配置文件位置,参数模式
#less /usr/share/doc/pam-0.99.3.0/txt/README.pam_limits
hard硬限制(不能达到的)
2.将模块应用到sshd服务,修改服务文件
#vi /etc/pam.d/sshd 添加:
session required pam_limits.so
session 控制用户进程的登录次数,文件大小,通过控制用户的会话进程来限制用户使用的资源
3.编缉pam_limits.so的配置文件/etc/security/limits.conf
redhat hard maxlogins 2
限制redhat登录到sshd服务的次数,不能达到2。
4.测试
#ssh -l redhat 192.168.0.22 第1个
#ssh -l redhat 192.168.0.22 第2个
表示同时最多可以有1个redhat用户登录
pam_rootok.so的应用
#chfn 改变用户的finger信息
普通用户使用这个命令修改信息时,需要输入密码才能使用,而root用户则不需要。
分析:
#more /etc/pam.d/chfn
第一行为auth sufficient pam_rootok.so
因为chfn的pam服务文件的第一行应用了pam_rootok.so模块,所以当root用户使用chfn时不需验证,不需要再往下,直接通过。
pam_userdb.so模块需要一个db数据库储存用户信息,具体如何使用可参考前面的vsftpd虚拟用户。
在使用PAM模块时,注意参考README.pam帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

1. First, click to open the Douyin app and click [Me]. 2. Click the three-dot icon in the upper right corner. 3. Click to enter [Settings]. 4. Click to open [Account and Security]. 5. Select and click [Log in to device management]. 6. Finally, click to select the device and click [Remove].

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app

1. After turning on the phone, select NetEase Cloud Music. 2. After entering the homepage, you can see the [Ranking List] and click to enter. 3. In the ranking list, you can select any list and click [New Song List]. 4. Select your favorite song and click on it. 5. Return to the previous page to see more lists.

As a trading platform, Xianyu requires you to register and log in to your account before using it. Users can set an ID name for their account. What if they want to check what their ID is? Let’s find out together below! Introduction to how to view personal nicknames on Xianyu. First, start the Xianyu app. After entering the homepage, switch to the page of selling idle, messages, and me, and click the [My] option in the lower right corner. 2. Then on my page we need to click [Avatar] in the upper left corner; 2. Then when we go to the personal homepage page we can see different information, we need to click the [Edit Information] button here; 4. Finally click We can see it later on the page where we edit information;

Kuaishou Live Companion is not only a powerful live broadcast auxiliary tool, but also a real-time insight platform for hot topics and trends created for broadcasters. Through this function, anchors can quickly capture the content that audiences are most concerned about, and then adjust the live content to make it more in line with the audience's tastes and interests. So how to check the hot video list in the Kuaishou Live Companion app? This tutorial guide will provide you with a detailed introduction to the steps. I hope it can help you. How to view the hot video list on Kuaishou Live Companion? The second step is to click on the daily video hot list. The third step is to check the daily video hot list.

Regardless of life or work, many people have long been deeply tied to WeChat and will be pulled into various groups at any time. So how many WeChat groups have you joined? You may immediately want to view the group chats in your address book, but only the WeChat groups you have saved in your address book will appear there, and other groups will not be visible. If you want to see all the WeChat groups you have joined, it is very simple: enter your nickname in the search box on the WeChat homepage, then find the group chat section in the search results, and click "More Group Chats" to view all related group chat information. Anyway, I was shocked. There were more than a hundred of them, and the scroll bar on the right became very small. Unfortunately, there is no specific number statistics... This method is also applicable to checking the QQ groups you have joined. PS: Some netizens also provided a trick:
