我有一台CentOS机器,下面我在access.conf设置:
root : ALL
然而,我可以通过rootlogin,仍然执行任务。 那么access.conf的工作是什么呢? 这里有什么问题吗?
在这里,你去了解如何激活access.conf
我没有在我的access.conf文件中添加以下内容
[root@lcoalhost ~]# tail -1 /etc/security/access.conf -:user1:ALL
我在文件“/etc/pam.d/sshd”中添加了以下内容
[root@localhost ~]# head -3 /etc/pam.d/sshd #%PAM-1.0 auth include system-auth account required pam_access.so #I added this line in the file
特别是第三行。
编辑完成之后,我尝试以user身份访问服务器:user1:
这是我在日志文件“/ var / log / secure”中看到的
Jan 1 16:40:06 localhost sshd[17981]: pam_access(sshd:account): access denied for user `user1' from `10.0.1.243' Jan 1 16:40:06 localhost sshd[17981]: Failed password for user1 from 10.0.1.243 port 3186 ssh2 Jan 1 11:10:06 localhost sshd[17982]: fatal: Access denied for user user1 by PAM account configuration
这里“user1”已被拒绝任何IP。 同样,你可以为任何用户做到这一点。
这里是root用户的日志
Jan 1 16:53:29 localhost sshd[19144]: pam_access(sshd:account): access denied for user `root' from `10.0.1.243' Jan 1 16:53:29 localhost sshd[19144]: Failed password for root from 10.0.1.243 port 3356 ssh2 Jan 1 11:23:29 localhost sshd[19145]: fatal: Access denied for user root by PAM account configuration
希望这可以帮助。