1、建立 /etc/sshusers 文件:
[root@server ~]# touch /etc/sshusers
2、把允许登陆的用户加入到此文件中:
[root@server ~]# echo “root” >> /etc/sshusers
[root@server ~]# echo “foo” >> /etc/sshusers
3、编辑 pam.d/sshd 文件,加入斜体加粗的那一行:
[root@server ~]# vi /etc/pam.d/sshd
#%PAM-1.0
#auth include system-auth
auth required pam_listfile.so item=user sense=allow file=/etc/sshusers onerr=fail
account required pam_nologin.so
account include system-auth
password include system-auth
session optional pam_keyinit.so force revoke
session include system-auth
session required pam_loginuid.so
然后 /etc/init.d/sshd reload