Pandora Pocket

IT系と日常系の備忘録。三日坊主。

前回までの設定でWebサーバーとしての機能は大概そろったはず。

次はセキュリティ問題に。

私のサイトはアップローダもあるので万が一ウイルスに感染したファイルがアップロードされたときに備えてアンチウイルスソフトウェアを導入。

一般的に使われているLinuxのアンチウイルスソフトはClamAV。でも、少々メモリーを食らいすぎるのが玉に瑕。常駐しているのかな?

というわけでもう少し軽いソフトウェアをインストール。

今回選んだのはF-Prot Antivirusというソフト。これも無料。

まずはF-Prot Antivirus for LinuxをDLする。

このソフトは解凍したフォルダを今後も利用するみたいなので(?)、あらかじめDL前に移動しておくなり、解凍先を指定しておいた方がいいかも。

こちらのサイトからDL。

wget http://files.f-prot.com/files/unix-trial/fp-Linux-i686-ws.tar.gz

DLしたら解凍。

tar xzvf fp-Linux-i686-ws.tar.gz

解凍が終わったら解凍されてできたフォルダに移動し、インストールファイルを実行。

cd ./f-prot/
./install-f-prot.pl

基本的には質問はEnterでOkだけど、たまにYes,Noの質問もある。これはYでいいはず。

以下インストール時の文言。

(c) FRISK Software International

http://www.f-prot.com/

You are about to install F-Prot Antivirus for Linux Workstations

on a Debian Linux 2.6.32 running on i686 into the '/f-prot'

directory

Be warned that the documentation and user manuals assume that

F-Prot is installed in the default directory '/opt/f-prot'.

F-Prot will run just fine from '/f-prot'

but you will of course have to adjust sample configuration and

such to match that change.

/f-prot/f-prot.conf already exists, not copying /f-prot/f-prot.conf.default to that location

Where do you want a symbolic link to 'F-Prot Antivirus command line scanner (fpscan)' to be created?

(Just press Enter to accept the default) [/usr/local/bin]:

Where do you want a symbolic link to 'section 8 manuals' to be created?

(Just press Enter to accept the default) [/usr/local/man/man8]:

/usr/local/man/man8 doesn't exist. Create it?

(Just press Enter to accept the default) [Y/n]: y

Where do you want a symbolic link to 'section 1 manuals' to be created?

(Just press Enter to accept the default) [/usr/local/man/man1]:

/usr/local/man/man1 doesn't exist. Create it?

(Just press Enter to accept the default) [Y/n]: y

Where do you want a symbolic link to 'section 5 manuals' to be created?

(Just press Enter to accept the default) [/usr/local/man/man5]:

/usr/local/man/man5 doesn't exist. Create it?

(Just press Enter to accept the default) [Y/n]: y

Changing file access permissions on the installed files and directories ...ok

Checking if you have an existing license key...yes

Found an existing license key in /f-prot/license.key, updating antivir.def ...

Downloading update (%100)

We've generated the following crontab entries to update the

antivir.def file via fpupdate. Updates will be run hourly at a

randomly picked minute to distribute load, and thus make your updates

faster than if they were run during obvious high load times, e.g. on

the hour.

The global crontab entry we made to add to /etc/crontab is the following:

36 * * * * root /f-prot/fpupdate > /dev/null

Would you like to have this crontab appended to /etc/crontab?

(Just press Enter to accept the default) [Y/n]: y

All done!

If you reconfigured your MTA you should restart it now to activate the changes.

Have a nice day

Frisk software (www.f-prot.com)

実行コマンドはこんな感じ。

結構コマンドは細かく指定できるそうなので調べてみるといいかも。私はここここを参考にした。

fpscan --disinfect /home -o /var/log/fprot/scan.log

なお、現時点では定期的にスキャンするように設定されていないのでCronに設定を書き込んでおく。

crontab -e
0 3 * * 3 fpscan --disinfect /home -o /var/log/fprot/scan.log

ウイルス対策はこんな感じ。

本当はほかにもルートキット対策などをするべきなのかもしれないけど今回は割愛。折を見て入れる予定。

つぎにSSH関連のセキュリティ向上を行う。

現在においてSSHはパスワード認証になっている。

ただし、これだと万が一パスワードが流出したり辞書攻撃などで見つかってしまった場合なすすべもなくなるので、鍵認証を導入してセキュリティ向上を図る。

ssh-keygen -t rsa
cd /home/ユーザー名/.ssh
mv ./id_rsa.pub ./authorized_keys
chmod 600 authorized_keys

ついでにhomeディレクトリのパーミッションを変更して他のユーザーのディレクトリを参照できないようにする。

この場合homeディレクトリのパーミッションは710や711でいいみたい。

また、できることならSSHにchroot設定をしておいた方がいいとかどうとか。

次の記事に続く