[FreeBSD] DenyHosts 設定在 hosts.allow 注意事項

DenyHosts 是一套用 Python 跟 shell script 寫出來的 open source base on Linux or FreeBSD (/var/log/secure on Redhat, /var/log/auth.log on Mandrake, FreeBSD, etc…),用來阻擋 SSH Server 被攻擊,之前寫一篇 FreeBSD 安裝設定教學,有一點沒有注意到,就是打開 /etc/hosts.allow,注意要把 ALL : ALL : allow 放到最後一行,跟 iptables 設定原理是一樣的,會從第一條規則開始比對,如果比對成功,下面的 rule 就會略過比對了,參考英文說明: Start by allowing everything (this prevents the rest of the file from working, so remove it when you need protection). The rules here work on a “First match wins” basis. /etc/hosts.deny 已經被 FreeBSD 棄用,所以必須把 allow 跟 deny 的 rule 都寫到 hosts. [Read More]

[FreeBSD]利用 DenyHosts 軟體擋掉暴力破解 ssh 的使用者

不管是架設好 Linux 跟 FreeBSD 通常都會有國外的 hacker 來 try 機器的 SSH 帳號密碼,我想這是很正常的,網路上也提供很多方法來分析 Log 檔,FreeBSD:/var/log/auth.log,我可以分析檔案,然後再利用 firewall like ipfw or pf 的方式來達到,或者是利用寫到 /etc/hosts.deny 來達到 Block 的功能,網路上有很多工具可以用,例如 DenyHostssshguard 或者是 sshit,可以參考我之前寫的一篇利用 sshit 來達到阻擋 ssh 使用者,然而今天來介紹一下 DenyHosts 再 FreeBSD 底下如何設定,還蠻方便的。 首先利用 ports 安裝,DenyHosts 是利用 python 的程式語言寫出來的:

Port:   denyhosts-2.6_2
Path:   /usr/ports/security/denyhosts
Info:   Script to thwart ssh attacks
Maint:  janos.mohacsi@bsd.hu
B-deps: python25-2.5.2_3
R-deps: python25-2.5.2_3
WWW:    http://denyhosts.sourceforge.net/

/* 利用 ports 安裝 */
cd /usr/ports/security/denyhosts; make install clean
[Read More]