PAM认证机制详情

[root@yinzhengjie ~]# more /etc/pam.d/su | grep pam_rootok.so
#auth sufficient pam_rootok.so
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# su yinzhengjie
Password:
[yinzhengjie@yinzhengjie root]$ exit
exit
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# more /etc/pam.d/su | grep pam_rootok.so
auth sufficient pam_rootok.so
[root@yinzhengjie ~]# su yinzhengjie
[yinzhengjie@yinzhengjie root]$
[yinzhengjie@yinzhengjie root]$ exit
exit
[root@yinzhengjie ~]#
案例展示:(限制root切换用户也需要密码)
[root@yinzhengjie ~]# more /etc/pam.d/sshd | grep pam_access.so
auth required pam_access.so
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# tail - /etc/security/access.conf
#Add by yinzhengjie
-:root:ALL EXCEPT 10.0.0.0/ #只让root从10.0.0./24的网段访问
#-:root:10.0.0.0/ #拒绝从10.0.0./24这个C的地址访问过来。
#-:root:ALL EXCEPT 10.10.0.161 #拒绝从10.10.0.161这个IP访问过来。
[root@yinzhengjie ~]#
案例展示:(控制访问的源IP地址)
[root@yinzhengjie ~]# grep listfile /etc/pam.d/sshd
auth required pam_listfile.so item=user sense=allow file=/etc/yinzhengjie_ssh_users onerr=fail #注意,“onerr=fail”表示当文件“/etc/yinzhengjie_ssh_users”不存在时,默认为fail。
[root@yinzhengjie ~]# > /var/log/secure
[root@yinzhengjie ~]# tail -10f /var/log/secure
Feb :: yinzhengjie sshd[]: reverse mapping checking getaddrinfo for bogon [10.0.0.161] failed - POSSIBLE BREAK-IN ATTEMPT!
Feb :: yinzhengjie sshd[]: pam_listfile(sshd:auth): Couldn't open /etc/yinzhengjie_ssh_users
Feb :: yinzhengjie sshd[]: Failed password for root from 10.0.0.161 port ssh2
Feb :: yinzhengjie sshd[]: Received disconnect from 10.0.0.161: : The user canceled authentication.
^C
[root@yinzhengjie ~]# echo root > /etc/yinzhengjie_ssh_users
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# tail -10f /var/log/secure
Feb :: yinzhengjie sshd[]: reverse mapping checking getaddrinfo for bogon [10.0.0.161] failed - POSSIBLE BREAK-IN ATTEMPT!
Feb :: yinzhengjie sshd[]: pam_listfile(sshd:auth): Couldn't open /etc/yinzhengjie_ssh_users
Feb :: yinzhengjie sshd[]: Failed password for root from 10.0.0.161 port ssh2
Feb :: yinzhengjie sshd[]: Received disconnect from 10.0.0.161: : The user canceled authentication.
Feb :: yinzhengjie sshd[]: Accepted password for root from 10.0.0.161 port ssh2
Feb :: yinzhengjie sshd[]: pam_unix(sshd:session): session opened for user root by (uid=)
^C
[root@yinzhengjie ~]#
案例展示:(sshd的黑名单或白名单)
[root@yinzhengjie ~]# tail - /etc/security/time.conf
#Add by yinzhengjie
sshd;*;*;SaSu0900- #表示sshd服务的所有终端的所有用户只能在8-18点可以正登陆。
[root@yinzhengjie ~]#
案例展示:(基于时间限制sshd的访问)
[root@yinzhengjie ~]# grep pam_tally2.so /etc/pam.d/sshd
auth required pam_tally2.so deny= even_deny_root root_unlock_time= unlock_time= #表示当用户输入次数超过2次时,锁定用户60秒,因此这里的“even_deny_root ”表示包括root用户,“root_unlock_time”表示root用户锁定的时间,“unlock_time”表示其他用户锁定的时间。
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# pam_tally2 --reset -u root #这里表示手动解锁。
Login Failures Latest failure From
root
[root@yinzhengjie ~]#
案例展示:(实现防止对sshd暴力破解)
[root@yinzhengjie ~]# ulimit -a
core file size (blocks, -c)
data seg size (kbytes, -d) unlimited
scheduling priority (-e)
file size (blocks, -f) unlimited
pending signals (-i)
max locked memory (kbytes, -l)
max memory size (kbytes, -m) unlimited
open files (-n)
pipe size ( bytes, -p)
POSIX message queues (bytes, -q)
real-time priority (-r)
stack size (kbytes, -s)
cpu time (seconds, -t) unlimited
max user processes (-u)
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[root@yinzhengjie ~]# ulimit -n [root@yinzhengjie ~]#
[root@yinzhengjie ~]# tail - /etc/security/limits.conf
#Add by yinzhengjie
* soft nofile
* hard nofile
* soft nproc
* soft cpu
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# exit
logout
Last login: Sun Feb :: from 10.0.0.161
[root@yinzhengjie ~]# ulimit -n [root@yinzhengjie ~]#
案例展示:(调整最大打开的文件数)
[root@yinzhengjie ~]# which sshd
/usr/sbin/sshd
[root@yinzhengjie ~]# which login
/bin/login
[root@yinzhengjie ~]# ldd /usr/sbin/sshd | grep pam
libpam.so. => /lib64/libpam.so. (0x00007f2c196cf000)
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# ldd `which login` | grep pam #注意,ldd命令是查看进程文件支持的动态库,而ldconfig是可以查看已经加载的动态库。我们可以用“ldconfig -p”来打印当前操作系统已经加载的动态库。
libpam.so. => /lib64/libpam.so. (0x000000323b200000)
libpam_misc.so. => /lib64/libpam_misc.so. (0x0000003230a00000)
[root@yinzhengjie ~]#
PAM认证机制详情的更多相关文章
- PAM认证机制
PAM:Pluggable Authentication Modules 认证库:文本文件,MySQL,NIS,LDAP等 Sun公司于1995 年开发的一种与认证相关的通用框架机制 PAM 是关注如 ...
- CentOS-pam认证机制简介
前言 linux下PAM模块全称是Pluggable Authentication Module for linux(可插入式授权管理模块),该由Sun公司提供,在Linux中,PAM是可动态配置的, ...
- AIDE,sudo,TCP_Wrappers,PAM认证等系统安全访问机制
AIDE 高级入侵检测环境:是一个入侵检测工具,主要用途是检查文件的完整性,审计计算机上的那些文件被更改过了. AIDE能够构造一个指定文件的数据库,它使用aide.conf作为其配置文件.AIDE数 ...
- PAM认证
PAM认证 摘自: http://www.cnblogs.com/shenxm/p/8451889.html PAM(Pluggable Authentication Modules) Sun公司于1 ...
- 什么是PAM认证
PAM(Pluggable Authentication Modules )是由 Sun 提出的一种用于实现应用程序的认证机制.其核心是一套共享库,目的是提供一个框架和一套编程接口,将认证工作由程序员 ...
- Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结
Atitit HTTP认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结 1.1. 最广泛使用的是基本验证 ( ...
- WPS 认证机制
WPS 认证机制 WPS(Wi-Fi Protected Setup,Wi-Fi保护设置)(有的叫做AOSS.有的叫做QSS,不过功能都一致.)是由Wi-Fi联盟组织实施的认证项目,主要致力于简化无线 ...
- 基于Token的WEB后台认证机制
几种常用的认证机制 HTTP Basic Auth HTTP Basic Auth简单点说明就是每次请求API时都提供用户的username和password,简言之,Basic Auth是配合RES ...
- HTTP中的摘要认证机制
引子: 指定和服务器端交互的HTTP方法,URL地址,即其他请求信息: Method:表示http请求方法,一般使用"GET","POST". url:表示请求 ...
随机推荐
- 使用 spring-boot-devtools 进行热部署
2019/3/5 更新: 发现热部署不生效,出现页面显示error的错误,然后在 application.properties 中注释了下面两行成功实现热部署(直接删掉也可以) #spring.dev ...
- 解决 idea 中的 tomcat控制台 和cmd tomcat下的中文乱码问题(win10 64位)
原理:idea控制台里的日志默认是从tomcat的localhost.log 和 catalina.log 两个文件中读出来的. https://blog.csdn.net/zhaijingkui/a ...
- stl源码剖析 详细学习笔记 hashtable
//---------------------------15/03/24---------------------------- //hashtable { /* 概述: sgi采用的是开链法完成h ...
- centos7 部署mysql-5.7.20
一.系统环境 系统:CentOS Linux release 7.5 mysqlb进制包:mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz 1)依赖包安装 yum ...
- 金蝶K3 11.0 WISE版本盘点机PDA条码数据采集器仓库条码管理
- TCP三路握手,本质是一个通信原理相关的问题
在通信系统中,最基本的信息的传递都需要两步,发送方发送的消息和对方的回复确认:A->B Send, B->A Reply(ACK).如果多接触一下其他行业的通信流程和规范,例如航空.铁路调 ...
- “数学口袋精灵”App的第一个Sprint计划
一.现状 我们这个团队想制作一个关于运算的游戏类型手机软件,针对我们这个学期的Android软件开发的课程,制作出一个关于数学算术游戏软件. 二.任务认领 第一阶段先把静态网页制作出来,各自的任务: ...
- Feature List
我组最终决定所做的软件工程项目是Bing词典(UWP)的背单词模块,下面是初步定下的Feature List. 按用户场景变化顺序列举(假设是新用户): 1.用户可通过点击“背单词”标识或按钮进入背单 ...
- 我与git“美妙”的一天
今天是第一天使用git,苦不堪言,感觉服务器和自己都要爆炸了,弄了半天才马马虎虎会了一点,基本流程如下 1.在mukever.online注册用户 2.下载git for windows(一个客户端) ...
- SQLServer2008只能编辑前面200行数据
设置编辑所有行:操作步骤:打开数据库-〉工具-〉选项-〉sqlserver对象资源管理器-〉命令 把200改为0,即可编辑所有行了