linux限制使用者本地或ssh遠端登入
阿新 • • 發佈:2019-02-19
一:限制本地登入
1. 限制普通使用者本地登入
把auth required pam_succeed_if.so user = root quiet放到/etc/pam.d/login檔案的第一行即可
2.限制root使用者本地登入,只需要把 user = root 改成 user != root 即可
二:限制普通使用者ssh遠端登入
1.編輯/etc/pam.d/sshd檔案,修改部分如下紅色字型部分
[root@node1 ~]# cat /etc/pam.d/sshd
#%PAM-1.0
auth required pam_sepermit.so
auth include password-auth
# account required pam_nologin.so //註釋掉改行
account required pam_access.so //增加改行
account include password-auth
password include password-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session optional pam_keyinit.so force revoke
session include password-auth
2.編制/etc/security/access.conf檔案,在最後增加下面這行
-:ALL EXCEPT root:ALL
+ :ALL :ALL //匹配其他預設規則