Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".

Rocky Linux 8.4 ; antivirus, etc.

1.Synchronize the server time with Japan Standard Time.

Edit chrony.conf

[root@Lepard ~]# vi /etc/chrony.conf
Per line 3.
pool 2.centos.pool.ntp.org iburst

server ntp.nict.jp
server ntp1.jst.mfeed.ad.jp
server ntp2.jst.mfeed.ad.jp
Restart chrony
[root@Lepard ~]# systemctl restart chronyd.service
Enable chrony even after reboot

[root@Lepard ~]# systemctl enable chronyd.service

Checking the status (behavior) of chronyd
root@Lepard ~]# chronyc sources

It will be displayed as shown below.
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===========================================
^+ ntp1.jst.mfeed.ad.jp  2  9  377 125 -462us[ -462us] +/- 93ms
^* ntp2.jst.mfeed.ad.jp  2 10 377 1019 +140us[ +265us] +/- 97ms
If you see the “*” mark, synchronization is complete.

2.virus protection

2.1 Clam AntiVirus installation and definition/configuration file settings

①Installing Clam AntiVirus

[root@Lepard ~]# dnf –enablerepo=epel -y install clamav clamav-update clamav-scanner-systemd

➁Virus definition file update setting
Edit virus definition file update setting file

[root@Lepard ~]# vi /etc/freshclam.conf 
■Line 8.
# Comment or remove the line below.
#Example ← Add # to the beginning of the line and comment it out
■Line 75.
Insert “#” at the beginning of the line “DatabaseMirror database.clamav.net” and add “DatabaseMirror db.jp.clamav.net”.
and add “DatabaseMirror db.jp.clamav.net”.
#DatabaseMirror database.clamav.net
DatabaseMirror db.jp.clamav.net
■Per line 151
Add “NotifyClamd /etc/clamd.d/scan.conf”.
#NotifyClamd /path/to/clamd.conf
NotifyClamd /etc/clamd.d/scan.conf

➂Update virus definition files

[root@Lepard ~]#  freshclam
ClamAV update process started at Tue Mar 10 10:22:58 2020daily database available for download (remote version: 25746)

④Edit Clam AntiVirus configuration file

[root@Lepard ~]# vi /etc/clamd.d/scan.conf
■Line 8.
# Comment or remove the line below.
#Example ← Add # to the beginning of the line and comment it out
■Line 14.
# Default: disabled
LogFile /var/log/clamd.scan ← Uncomment
■Line 77.
# Default: disabled
PidFile /run/clamd.scan/clamd.pid ← Uncomment
■Line 96.
# Path to a local socket file the daemon will listen on.
# Default: disabled (must be specified by a user)
LocalSocket /run/clamd.scan/clamd.sock ← Uncomment
■Line 219.
# Run as another user (clamd must be started by root for this option to work)
# Default: don’t drop privileges
#User clamscan ← Add # to the beginning of the line and comment it out(Make sure it runs with root privileges)

⑤Start Clam AntiVirus

[root@Lepard ~]# systemctl start clamd@scan ← Start clamd
[root@Lepard ~]# systemctl enable clamd@scan ← clamd auto-start setting
[root@Lepard ~]# systemctl is-enabled clamd@scan

enabled
[root@Lepard ~]# systemctl status clamd@scan ← operation check
● clamd@scan.service – clamd scanner (scan) daemon
Loaded: loaded (/usr/lib/systemd/system/clamd@.service; enabled; vendor pres>
Active: active (running) since Sun 2020-03-22 20:13:31 JST; 22min ago
Docs: man:clamd(8)
man:clamd.conf(5)
https://www.clamav.net/documents/
Main PID: 19465 (clamd)
Tasks: 2 (limit: 26213)
Memory: 873.7M
CGroup: /system.slice/system-clamd.slice/clamd@scan.service
mq19465 /usr/sbin/clamd -c /etc/clamd.d/scan.conf

2.2 Configure virus scanning and periodic execution

1)Perform virus scanning.
■If the virus is not detected

[root@Lepard ~]# clamscan –infected –remove –recursive
———– SCAN SUMMARY ———–
Known viruses: 6780306
Engine version: 0.100.2
Scanned directories: 5
Scanned files: 8
Infected files: 0 ←If no virus is detected, the value here is displayed as “0”.
Data scanned: 0.03 MB
Data read: 0.02 MB (ratio 2.00:1)
Time: 14.258 sec (0 m 14 s)

■When a virus is detected

Download a test virus
[root@Lepard ~]# wget http://www.eicar.org/download/eicar.com
[root@Lepard ~]# clamscan –infected –remove –recursive
/root/eicar.com: Eicar-Test-Signature FOUND ← virus detection
/root/eicar.com: Removed. ← virus removal
———– SCAN SUMMARY ———–
Known viruses: 6780306
Engine version: 0.100.2
Scanned directories: 5
Scanned files: 12
Infected files: 1 ←One virus detected.
Data scanned: 0.03 MB
Data read: 0.02 MB (ratio 2.00:1)
Time: 12.810 sec (0 m 12 s)

2)Deployment of automatic virus scan execution scripts

Create clamscan.sh with the following contents
[root@Lepard ~]# vi /var/www/system/clamscan.sh
#!/bin/bash
PATH=/usr/bin:/bin
# excludeopt setup
excludelist=/var/www/system/clamscan.exclude
if [ -s $excludelist ]; then
for i in `cat $excludelist`
do
if [ $(echo “$i”|grep \/$) ]; then
i=`echo $i|sed -e ‘s/^\([^ ]*\)\/$/\1/p’ -e d`
excludeopt=”${excludeopt} –exclude-dir=$i”
else
excludeopt=”${excludeopt} –exclude=$i”
fi
done
fi
# signature update
freshclam
# virus scan
clamscan –recursive –remove ${excludeopt} /
[root@Lepard ~]#  chmod 700 clamscan.sh
[root@Lepard ~]#  echo “/sys/” >> /var/www/system/clamscan.exclude
[root@Lepard ~]#  echo “/proc/” >> /var/www/system/clamscan.exclude

3)Set up a regular virus scan.

[root@Lepard ~]# crontab -e
0 1 * * * /var/www/system/clamscan.sh > /dev/null 2>&1
Run a scan at 1 a.m. every day with the above settings

タイトルとURLをコピーしました