2012年11月25日日曜日

DenyHosts-2.6の導入


結構みんな攻撃されているようで、便利なツールがありました。
DenyHosts-2.6です。
secure.logをチェックしてsshdにトライしてくるIPを/etc/hsots.denyに登録してブロックしてくれるツールです。

installして/usr/share/denyhostsのdenyhosts.cfgを設定します。
OS X用に変更です。


# /usr/share/denyhosts 151 >diff -U0 denyhosts.cfg-dist denyhosts.cfg
--- denyhosts.cfg-dist 2006-08-20 23:09:57.000000000 +0900
+++ denyhosts.cfg 2012-11-25 10:10:35.000000000 +0900
@@ -12 +12 @@
-SECURE_LOG = /var/log/secure
+#SECURE_LOG = /var/log/secure
@@ -22 +22 @@
-#SECURE_LOG = /private/var/log/asl.log
+SECURE_LOG = /private/var/log/secure.log
@@ -195 +195 @@
-LOCK_FILE = /var/lock/subsys/denyhosts
+# LOCK_FILE = /var/lock/subsys/denyhosts
@@ -198 +198 @@
-#LOCK_FILE = /var/run/denyhosts.pid
+LOCK_FILE = /var/run/denyhosts.pid


ただ、そのまま動かしてもなんか/var/log/denyhostsにエラーが出ています。

2012-11-25 09:51:41,486 - denyhosts   : ERROR    regex pattern ( User (?P<user>.*)
 not allowed because not listed in AllowUsers ) is missing 'host' group

googleに聞いてみると、同じ問題に当たっている人がいました。

- DenyHosts/regex.py:FAILED_ENTRY_REGEX7 = re.compile(r"""User (?P<user>.*) not allowed because not listed in AllowUsers""")
+ DenyHosts/regex.py:FAILED_ENTRY_REGEX7 = re.compile(r"""User (?P<user>.*) .*from (?P<host>.*) not allowed because not listed in AllowUsers""")

これでうまく登録されるようになりました。

早速/etc/hosts.denyに幾つか登録されています。
sshd: 120.128.0.83
sshd: 218.196.56.73
sshd: 42.121.33.197
sshd: 218.20.224.17
sshd: 199.195.214.244

0 件のコメント:

コメントを投稿