Ubuntu Server23.04 ; Anti-Virus(Clamav) , Mail Server

1.Anti-virus software Clamav installed

1.1 Install

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

1.2 Virus definition updates

Change configuration file

1.3 Virus Check Confirmation

①Running manual virus checks

Infected files: 0, so no virus

②Download a test virus to detect viruses
Download a trial harmless virus to test detection

The virus is notified with the message "FOUND" and "Infected files: 1". Also, since the "--remove" option is attached, the test virus has been removed.

1.4 Create a script file to do a full scan

①Contents of clam-full.sh (new)

②grant execution authority

③Create a folder for virus quarantine (if it already exists, it is OK, but if it does not, a runtime error will occur because it is specified as an excluded directory in the above script).

④I'll give it a try and run it.

LibClamAV Warning: cli_scanxz: decompress file size exceeds limits - only scanning 27262976 bytes
If the above message is displayed, run with the "--max-filesize=200M" and "--max-scansize=200M" options.

⑤Scheduled virus scan execution with cron

2. Email software installation

2.1 Postfix : Installation/Configuration

Install Postfix and build an SMTP server. 25/TCP is used for SMTP.
To prevent unauthorized mail relay, use the SASL function of Dovecot (see below), and configure Postfix so that authentication is required even for outgoing mail.

①Install

Installation Status Screen
You will be asked to select a general configuration setting, select "No Configuration" to set it manually later.

②Configuration File Edit

Editing Contents

③master.cf edit

Editing Contents

④Reflecting settings

2.2 Dovecot : Installation/Configuration

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

②Configuration Reflection

2.3 Port Open

2.4 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, you do not need to make any additional settings, only register an OS user.

①Mail Client Install

②Mailboxes are set to refer to Maildir

2.5 operation check ①

①Test sending mail
Send test mail to yourself [mail (user name)@(host name)].

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 : any name
Email addtess : huong@korodes.com" that I just added.
Password : Password for user huong
Click on "Configure manually"

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

⑤"The following settings were found by probinfg the given server" Displayed

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

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

2.7 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

②"15-content_filter_mode" editing

③Register your own domain name

④"main.cf" editing

⑤"master.cf" editing

Editing Contents

⑥Configuration Reflection

⑦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.

2.8Applied spamassassin to mail server Postfix

2.5.1 spamassassin install

①Install

②SpamAssassin Settings
The configuration file is "/etc/mail/spamassassin/local.cf".

Use by default with no additional configuration
Creating a Maildir for storing spam mail
Create a directory for storing spam mails in Maildir format
Create a directory ".Spam" for storing spam mails in Maildir format
Creation must be done by the target user.

2.5.2 Procmail Preparation

①Procmail Install

If installed, the following results are returned

②Procmail Settings
If you put the filter in "/etc/procmailrc", which is in charge of the entire mail filter, the filter will be applied to all users.
If you put it in "/home/username/.procmailrc", which is the mail filter file for each user, the filter will be applied only to that user.
In this case, to apply the filter to all users, we will put it in "/etc/procmailrc".

procmailrc description (newly created)

2.5.3 Postfix Configuration

① "main.cf" editing

②Reflecting and activating settings

2.5.4Spam Email Learning

Learning all the contents of all users' ".Spam" directories as spam mail
①Learning of spam mail

②Normal mail learning

③Create a script and register it with Cron
Name the file "spam-learns.sh" and place it under /opt/script/.
After saving the script, give it executable access as "chmod 750 spam-learns.sh".

spam-learns.sh Contents

After spam-learns.sh is created, create a definition file directly under /lib/systemd/system.
The name should end in .service, like spam-learns.service.
Define the Type as simple.

Contents of spam-learns.service

④Send a blank email to yourself in Thunderbird, etc., and if you see the following message in the header of the received email, you have succeeded.

Copied title and URL