星期六, 12月 31, 2011

安裝 DenyHosts 防止 SSH 暴力破解

實在是受不了大量外部 IP 狂駭你的 SSH 嘛?

請服用 DenyHosts ~

FreeBSD 請用 ports 安裝: /usr/ports/security/denyhosts/
Linux 請到 http://denyhosts.sourceforge.net 下載安裝

官方安裝說明:

To run denyhosts from startup, add denyhosts_enable="YES" in your /etc/rc.conf.
Configiration options can be found in /usr/local/etc/denyhosts.conf
-------------------------------------------------------------------------------
In order to proper working of denyhosts
1. edit your /etc/hosts.allow file and add:
sshd : /etc/hosts.deniedssh : deny
sshd : ALL : allow
2. issue the following command if /etc/hosts.deniedssh does not exist yet
touch /etc/hosts.deniedssh
-------------------------------------------------------------------------------

/usr/local/etc/denyhosts.conf 基本設定完成後,/usr/local/etc/rc.d/denyhosts start 即可~

如需允許特定 IP 避免被鎖住,請在 DenyHosts WORK_DIR 目錄中新增一個 allow_hosts 每行一個IP,重啓 denyhosts 後即可排除特定 IP ~