RHEL 8反对使用pam_tally2命令。早期版本的pam_tally命令为我们提供了故障计数的数量。e.g
[root@Linux7 ~]# pam_tally2
Login Failures Latest failure From
testNG_Admin 2 08/21/19 04:58:57 /deve/pts/0随着pam_faillock被替换为pam_tally2,现在我们希望使用faillock命令。
但问题是,faillock命令没有给出故障计数,而是给出了所有细节。
例如:
[root@bsingh-vm4 ~]# faillock
a735c:
When Type Source Valid
ajit:
When Type Source Valid
2019-08-22 18:36:41 RHOST 172.18.252.88 V
2019-08-22 18:36:46 RHOST 172.18.252.88 V
2019-08-22 18:36:51 RHOST 172.18.252.88 V有什么方法可以让我用命令来计数吗?例如:
a735c 0
ajit 3提前谢谢!
发布于 2019-12-03 22:42:11
我们有一张票是开着的,RedHat要求同样的票。这是我想出的最好的办法。
对于我们的配置,当出现5次故障时,用户将被锁定。
在rhel8-实例中,我为testNG_Admin做了>5次失败;但是故障锁--用户只报告导致锁定的5次,如下所示:
[myActiveUser@rhel8-instance ~]$ sudo faillock --user testNG_Admin
testNG_Admin:
When Type Source Valid
2019-12-03 16:12:27 TTY pts/0 V
2019-12-03 16:12:39 TTY pts/0 V
2019-12-03 16:17:51 TTY pts/0 V
2019-12-03 16:17:56 TTY pts/0 V
2019-12-03 16:18:01 TTY pts/0 V想知道自用户被重置以来失败了多少次?(这就是pam_tally2所提供的)-不知道如何做到这一点!
但是,自上次成功登录以来,我们总共可以得到多少次失败。首先,让我们获得上次成功登录的时间。
[myActiveUser@rhel8-instance ~]$ sudo lastlog --user testNG_Admin
Username Port From Latest
testNG_Admin pts/0 Tue Dec 3 16:06:54 -0600 2019现在,由于失败的登录被保存在/var/log/btmp中,通过"lastb“访问,我们可以使用.注意用户is被截断("testNG_A")
sudo lastb --自(YYYYMMDDhhmmss)
[myActiveUser@rhel8-instance ~]$ sudo lastb testNG_Admin --since 20191203160654
testNG_A pts/0 Tue Dec 3 16:18 - 16:18 (00:00)
testNG_A pts/0 Tue Dec 3 16:18 - 16:18 (00:00)
testNG_A pts/0 Tue Dec 3 16:18 - 16:18 (00:00)
testNG_A pts/0 Tue Dec 3 16:18 - 16:18 (00:00)
testNG_A pts/0 Tue Dec 3 16:18 - 16:18 (00:00)
testNG_A pts/0 Tue Dec 3 16:17 - 16:17 (00:00)
testNG_A pts/0 Tue Dec 3 16:17 - 16:17 (00:00)
testNG_A pts/0 Tue Dec 3 16:12 - 16:12 (00:00)
testNG_A pts/0 Tue Dec 3 16:12 - 16:12 (00:00)
btmp begins Tue Dec 3 15:50:22 2019
[myActiveUser@rhel8-instance ~]$ sudo lastb testNG_Admin --since 20191203160654 | grep testNG_A | wc -l
9所以现在我们知道自从上次成功登录以来一共有9家.但是..。如果我们重置帐户,并且没有成功,我们仍然不知道失败的确切数目,因为帐户是解锁的,正如pam_tally2所显示的!
[myActiveUser@rhel8-instance ~]$ sudo faillock --user testNG_Admin --reset
[myActiveUser@rhel8-instance ~]$ sudo faillock --user testNG_Admin
testNG_Admin:
When Type Source Valid
[myActiveUser@rhel8-instance ~]$ sudo lastlog --user testNG_Admin
Username Port From Latest
testNG_Admin pts/0 Tue Dec 3 16:06:54 -0600 2019
[myActiveUser@rhel8-instance ~]$ su - testNG_Admin
Password:
Last login: Tue Dec 3 16:06:54 CST 2019 on pts/0
Last failed login: Tue Dec 3 16:18:27 CST 2019 on pts/0
There were 9 failed login attempts since the last successful login.
[testNG_Admin@rhel8-instance ~]$ exit
logout
[myActiveUser@rhel8-instance ~]$ sudo lastlog --user testNG_Admin
Username Port From Latest
testNG_Admin pts/0 Tue Dec 3 16:23:30 -0600 2019
[myActiveUser@rhel8-instance ~]$ sudo lastb testNG_Admin --since 20191203162330
btmp begins Tue Dec 3 15:50:22 2019
[myActiveUser@rhel8-instance ~]$ sudo lastb testNG_Admin --since 20191203162330 | grep testNG_A| wc -l
0https://unix.stackexchange.com/questions/536858
复制相似问题