需求:只允許root與u1可以ssh login至本機
1. 建立user list:
# vi /etc/ssh/ssh_users
root
u1
2. 修改/etc/pam.d/sshd:
#%PAM-1.0
#auth include system-auth
auth required pam_listfile.so item=user sense=allow file=/etc/ssh/ssh_users 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
立即生效~
* sense=allow 代表名列於/etc/ssh/ssh_users的user才可ssh login, 反過來說當sense=deny時代表ssh_users中的account不可ssh login。
*onerr=fail 代表當/etc/ssh/ssh_users無法開啟或是檔案不存在時,當作失敗,反之onerr=succeed代表不管能不能讀取到檔案都成功。
No comments:
Post a Comment