sshit - BBS

Table of Contents

/usr/ports/security/sshit
這個可以拿來擋惡意try ftp or ssh的IP
可以搭配pf ipfw等等
看板上沒有分享,自己用的時候有些問題
所以分享一下我的設定

===============安裝=============
#cd /usr/ports/security/sshit
#make install clean

===============設定=============
#vi /usr/local/etc/sshit.conf

# We use pf as firewall on default
FIREWALL_TYPE = ipfw <-- 我是用ipfw

# Number of failed login attempts within time before we block
MAX_COUNT = 3 <-- 失敗3次就鎖

# Time in seconds in which all failed login attempts must occur
WITHIN_TIME = 60 <-- 60秒內失敗三次就鎖

# Time in seconds to block ip in firewall
RESET_IP = 3600 <-- 3600秒後才解鎖

IPFW_CMD = /sbin/ipfw

# Make sure you don't have any important rules here already
IPFW_RULE_START = 50000 <-- ipfw rule的起始編號
IPFW_RULE_END = 59999 <-- ipfw rule的起始編號

#IPFW2_CMD = /sbin/ipfw 沒用到 我把他註解掉
#IPFW2_TABLE_NO = 0

===============/etc/syslog.conf設定==========
這邊的話 有些小地方要注意
#vi /etc/syslog.conf
auth.info;authpriv.info |exec /usr/local/sbin/sshit
#新增這行就好


注意的地方
1. 在設定 /etc/syslog.conf 時,原本的 auto.info;authpriv.info 不要註解掉,
否則 /var/log/auth.log 會看不到記錄。
2. 新加入的 sshguard 設定要放在原本的上方。
(一開始我都放最後一行,結果都沒效果,不知道為什麼,辜狗了才知道
,不過為什麼一定要這樣,我也不曉得)
3. 新的設定中的 |exec /usr/local/sbin/sshguard,在 | 和 exec 中間不能有空白。

參考:http://weblog.gilbert.tw/?p=250
//雖然他是用sshguard,但syslog.conf的地方可以參考

===========重新啟動syslogd==================
/etc/rc.d/syslogd restart


之後只要ipfw show就可以觀察到目前哪些IP是被block

或cat /var/log/auth.log
就會有sshit的訊息了

--

All Comments