天天看點

如何讓ssh隻允許指定的使用者登入

如何讓ssh隻允許指定的使用者登入

方法1:

在/etc/pam.d/sshd檔案第一行加入

auth required pam_listfile.so item=user sense=allow file=/etc/sshusers

onerr=fail

然後在/etc下建立sshusers檔案,編輯這個檔案,加入你允許使用ssh服務的使用者名,不用重新啟動sshd服務。

方法2:

pam規則也可以寫成deny的

auth required pam_listfile.so item=user sense=deny file=/etc/sshusers

onerr=succeed

方法3:

在sshd_config中設定AllowUsers,格式如

AllowUsers a b c

重新開機sshd服務,則隻有a/b/c3個使用者可以登陸

重要的伺服器可以來這麼多提高伺服器的安全性。。。。

本文轉自 houzaicunsky 51CTO部落格,原文連結:   13頁http://blog.51cto.com/hzcsky/475581

繼續閱讀