1. 限制root不能ssh登入
預設允許root帳號登入,這裡將#號去掉並改成不允許root用ssh登入
<dl></dl>
<dd><code>編輯 /etc/ssh/sshd_config 將 #PermitRootLogin Yes 改成 PermitRootLogin no</code></dd>
2. tcp_wrappers 套件限制連線的範圍
設定可以連線的IP
<dd><code>編輯 /etc/hosts.allow 新增 sshd: 192.168.100.10 , 61.222.7.214 </code></dd>
設定拒絕所有的連線,這樣一來便隻有/etc/hosts.allow允許的IP才能連入使用
<dd><code>編輯 /etc/hosts.deny 新增 sshd: ALL </code></dd>
3. Pam 認證機制隻允許某些帳號使用ssh連入
<dd><code>編輯 /etc/pam.d/sshd 新增 auth required pam_listfile.so item=user sense=allow file=/etc/ssh/allow_list onerr=succeed</code></dd>
<dd><code>編輯 /etc/ssh/allow_list 新增您想允許使用ssh登入主機的帳號 p.s. 一行一個帳號喔</code></dd>
編輯 /etc/passwd一般的帳號也不讓他們登入shell,如:
<dd><code>account:x:501:501::/home/account:/bin/false</code></dd>
參考自酷學園
<a href="http://phorum.study-area.org/viewtopic.php?t=33194&highlight=ssh++%E9%99%90%E5%88%B6root">http://phorum.study-area.org/viewtopic. ... %88%B6root</a>