待ち受けるデーモン(ここではsshdとして説明)に、セッションを許すIPを設定します。
sshサービスの強化(
サーバへのアクセス制御[接続元のネットワークを限定する])でも紹介していますが、ローカルIP(もしくは指定したグローバルIP)のみセッションの確立を許し、それ以外は全て除外するように指定します。
TCP Wrapper設定ファイルを確認
# cat /etc/hosts.deny
#
# hosts.deny This file describes the names of the hosts which are
# *not* allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow. In particular
# you should know that NFS uses portmap!
sshd: ALL
# cat /etc/hosts.allow
#
# hosts.allow This file describes the names of the hosts which are
# allowed to use the local INET services, as decided
# by the '/usr/sbin/tcpd' server.
#
sshd: 127.0.0.1 , 192.168.1.
セッションが確立されなかったログ(sshdが拒否した場合)
Feb 18 11:04:42 fedora sshd[9554]: refused connect from root::ffff:xxx.xxx.xxx.xxx (::ffff:xxx.xxx.xxx.xxx)
Feb 19 09:01:29 fedora sshd[7531]: refused connect from xxxx.co.jp (::ffff:xxx.xxx.xxx.xxx)
セッションが確立したログ(sshdが許可した場合)
Feb 20 00:02:28 fedora sshd[13185]: Accepted publickey for linux from ::ffff:192.168.1.10 port 1192 ssh2
|
ログパスのセキュアログの内容を取得してhtmlファイルを作成します。
サンプルではapacheのドキュメントルート「/var/www/html/」に「refusedssh.html」というファイルを作成します。
スクリプトは『
不正アクセス一覧の集計スクリプト』よりダウンロードして下さい。
ブラウザより「http://サーバのIPアドレス/refusedssh.html」でアクセスします。
以下のような画面が表示されるはずです。
htmlの部分については、不正アクセス集計スクリプト内の「htmlの作成」部分を各自変更してください。