エントリー

BlockSSHD to SSHGuard

自宅鯖へのブルートフォースアタックの対策ツールを変更してみました。

背景

自宅鯖を FreeBSD 9.0 にアップグレードした際、Perl も一気に 5.16.2 までアップグレードを掛けたんですが、そんときに、BlockSSHD が動かなくなってしまい、しかたなく再 make deinstall && make && make install でもしようかな、と思っておりましたところ・・・

# pkgdb -Ff
Stale origin: 'security/blocksshd': perhaps moved or obsoleted.
-> The port 'security/blocksshd' was removed on 2012-03-03 because:
        "Removed: security/sshguard is more active and a better tool"
-> Hint: blocksshd-1.3 is not required by any other package
-> Hint: checking for overwritten files...
 -> No files installed by blocksshd-1.3 have been overwritten by other packages.
Deinstall blocksshd-1.3 ? [no] n

Ports から、BlockSSHD が削除されてました。

「代わりに、security/sshguard を使ってね!」と、言われちゃったので、移行作業をすることに。

移行

まずは、BlockSSHD を、アンインストール。

# pkg_deinstall blocksshd-1.3
--->  Deinstalling 'blocksshd-1.3'
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ...  done]

SSHGuard をインストールしてみる。複数のバックエンドに対応しているみたいで、うちの環境では、PF (Packet Filter) 版をインストールしてみました。

# portinstall security/sshguard-pf
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ...  done]
[Gathering depends for security/sshguard-pf  done]
--->  Installing 'sshguard-pf-1.5_2' from a port (security/sshguard-pf)
--->  Building '/usr/ports/security/sshguard-pf'
===>  Cleaning for sshguard-pf-1.5_2
===>  Extracting for sshguard-pf-1.5_2
=> SHA256 Checksum OK for sshguard-1.5.tar.bz2.
===>  Patching for sshguard-pf-1.5_2
===>  Applying FreeBSD patches for sshguard-pf-1.5_2
===>  Configuring for sshguard-pf-1.5_2
...(略)...
===>  Building for sshguard-pf-1.5_2
...(略)...
--->  Installing the new version via the port
===>  Installing for sshguard-pf-1.5_2
===>   Generating temporary packing list
...(略)...
===> Installing rc.d startup script(s)
 ##########################################################################
  Sshguard installed successfully.
  To activate or configure PF see http://sshguard.sf.net/doc/setup/blockingpf.html
  Your /etc/syslog.conf has been added a line for sshguard; uncomment it
  and use "/etc/rc.d/syslogd reload" for activating it.
  Alternatively, you can also start sshguard as a daemon by using the
  rc.d script installed at /usr/local/etc/rc.d/sshguard .
  See sshguard(8) and http://sshguard.sourceforge.net for additional info.
 ##########################################################################
===>   Compressing manual pages for sshguard-pf-1.5_2
===>   Registering installation for sshguard-pf-1.5_2
===>  Cleaning for sshguard-pf-1.5_2
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ...  done]

インストールが完了したら、公式サイトの ドキュメント を参考にしながら、PF設定ファイルを編集。その際、BlockSSHD時の設定が残っているのを、忘れずに削除。

# vim /etc/pf.conf

ext_if = "bge0"
- table <blocksshd> persist
+ table <sshguard> persist
set block-policy drop
set loginterface $ext_if
- block in quick on $ext_if from <blocksshd> to any
+ block in quick on $ext_if proto tcp from <sshguard> to any port 22 label "ssh bruteforce"

~
:wq

PFに、新しい設定を適用。

# pfctl -f /etc/pf.conf
No ALTQ support in kernel
ALTQ related functions disabled

FreeBSDの起動設定ファイルに、SSHGuardを追加。その際、BlockSSHDの削除を忘れずに、と。

# vim /etc/rc.conf

...(略)...
- blocksshd_enable="YES"
+ sshguard_enable="YES"
...(略)...

~
:wq

そして、SSHGuardサービスを起動するッ!

# /usr/local/etc/rc.d/sshguard start
Starting sshguard.

これで、移行が完了。

ページ移動

トラックバック

  • トラックバックはまだありません。

トラックバックURL

http://chsmea.net/~mioproject/freo/trackback/180

コメント

  • コメントはまだありません。

コメント登録

  • コメントを入力してください。
登録フォーム
名前 *
URL
コメント *
閲覧制限 *
【スパム対策】 2 × 2 × 2 = ? (半角数字で)

ユーティリティ

user profile

calendar

032024/0405
S M T W T F S
- 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 - - - -

tag cloud