Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".(Japanese Version)

Debian12 ; Anti-virus(Clamav) 、Mail Server

1.Antivirus software Clamav installed

Install Clam AntiVirus, a free anti-virus software for Linux, as an anti-virus measure.
By installing this anti-virus software, you can not only scan the entire server for viruses, but also scan incoming and outgoing mail for viruses if you build and configure a mail server.

1.1 Install

The clamav-related configuration files are installed in the /etc/clamav/ folder.

1.2 Virus Definition Update

Edit configuration file

Automatic virus definition update confirmation
Ensure that the service is registered for automatic virus definition updates.

It appears as follows

Logs are recorded in the file /var/log/clamav/freshclam.log.

1.3 Virus Check Confirmation

①Running manual virus checks

Infected files: 0, so no virus

②Virus detection by downloading test viruses
Download a harmless virus and test it for detection.
Log in as a general user and check

As you can see, the virus is notified with the message "FOUND" and "Infected files: 1". The "--remove" option was also added, so the test virus was removed.

1.4 Create a script file to do a full scan

①Create a script file storage directory (/opt/script) in advance.

②Create script file

Contents of clam-full.sh (new)

③execute authorization

④Create a folder for virus quarantine
If not, a runtime error will occur because the above script specifies it as an excluded directory.

⑤Script Execution

Takes quite a long time to complete.
Logs are recorded in the /var/log/clamav/clamscan.log file.

⑤Scheduled virus scan execution with cron

In the above example, it runs regularly every Monday at 2:00 AM.

2. Mail server installation

Postfix was developed as a Mail Transport Agent (MTA) to replace sendmail, and is a mail server that is highly compatible with sendmail, secure, easy to maintain, and fast.
In addition, since Postfix only functions as an SMTP server for sending mail, the POP server Dovecot for receiving mail will be installed separately in the latter half.

2.1 Postfix : Installation Configuration

①Install Postfix
Install Postfix and build an SMTP server; SMTP uses 25/TCP.
To prevent unauthorized mail relay, use the SASL function of Dovecot, described below, and configure Postfix so that authentication is also required for sending.

You will be asked to select general configuration settings, select "No configuration " to set them manually later

②Edit configuration file (main.cf)

Editorial content

Edit configuration file (master.cf)

Editorial content

Reflect settings, reboot

2.2 Dovecot : Installation Configuration

①Install Dovecot
Install Dovecot and build a POP/IMAP server, using 110/TCP for POP and 143/TCP for IMAP.

②Configure Dovecot to provide SASL functionality for Postfix

Reflect settings, reboot

2.3  Email User Account Registration

Register a user account for e-mail.
This setting is for when a user account on the OS is also used for e-mail.
If you want to use mail with a user account on the OS, no additional configuration is required, just register the OS user

Mail client installed

②Mailboxes are set to refer to Maildir

2.4 Opening Ports

2.5 operation check ①

①Send test mail to yourself [mail (user name)@(host name)].
user name : huong

Ctrl + D key to exit the main text

Check incoming mail

2.6 operation check ②

Set up and confirm your account in Mozilla Thunderbird

①Start Thunderbird, and click "Tools", "Account Settings".

②「Account Actions」「Add Mail Account」

③Your full name" is an optional name
Email addtess" is "huong@korodes.com" added earlier
Password" is the password for user huong
Click on "Configure manually"

④Set "INCOMMING SERVER" and "OUTGOING SERVER" as shown below and click "Re-test".

⑤The "Server Found" message appears.(The following settings were found by probinfg the given server)

After clicking "Done," the following "Warning" appears, but there is no problem, so click "Confirm.

⑥Click "Finish" when "Account syccessfuly created" is displayed.

3 Applied ClamAV to mail server Postfix

Set up Postfix and Clamav to work together to scan incoming and outgoing mail in real time.

①Install Amavisd and Clamav Daemon and start Clamav Daemon

If the server is not using a fully qualified domain name (FQDN) as the hostname, Amavis may fail to start. Also, since the OS hostname may change, set a valid hostname directly in the Amavis configuration file

Virus Scan Enable

Register your own domain name

Edit configuration file (Main.cf)

Edit configuration file (master.cf)

Editorial content

Settings reflect

When you send an e-mail to yourself on Thuderbird, etc., it is successful if you see the following message in the header of the incoming e-mail.

4 Apply spam checks to the mail server

4.1 Spam checking using spamassassin and procmail

①spamassassin and procmail installation

➁Configure procmail

If you want to apply the settings to all users
Create /etc/procmailrc
To configure for each individual, create a ~/.procmailrc in each user's home directory.

Create /etc/procmailrc this time

Contents of procmailrc

➂Create a .Spam directory in each user's ~/Maildir directory

④Edit postfix configuration file

⑤Restart postfix and spamassassin

⑥Confirmed by Thudrtbird
If you send an e-mail to yourself and the header displays the following, it is normal.

4.2 Spam Email Learning

SpamAssassin's email learning functionality improves the accuracy of its judgments

①Learns all contents of ".Spam" directory as spam mail

➁Learning of non-spam mail (normal mail)

➂Creating scripts for automatic learning

④SpamAssassin automatically starts at system startup

Copied title and URL