How to Install and Use Linux Malware Detect (LMD) with ClamAV on CentOS 7
There is less risk of malevolent software on Linux and Unix systems compared to other operating systems, but they are not necessarily immune to the threat of malware and viruses. Linux Malware Detect (LMD) is a free, open source malware scanner for Linux designed especially for mitigating malware risks in a shared hosting environment. It is often used in conjunction with ClamAV as an antivirus engine. LMD itself is licensed under the GNU General Public License, version 2, and the source is hosted on Github.
In order to follow this guide, you will need the following:
• 1 Node (Cloud Server or Dedicated Server) running a clean installation of CentOS 7.
• Root access to the server
The first step is to install LMD. You will need to install it from source, so download the installation tarball from the project’s web site.
Extract the tarball into your /usr/src/ folder, and then make it your current working directory.
tar -xvf maldetect-current.tar.gz
You can complete the installation by using the installation script.
Configuring Linux Malware Detect (LMD)
LMD’s configuration is stored in conf.maldet. We’ll need to make some changes to the default setup, so open this file in an editor.
Into the file, modify these following sections:
# Linux Malware Detect vX.X.X
# [ EMAIL ALERTS ]
# The default email alert toggle
# [0 = disabled, 1 = enabled]
# The subject line for email alerts
email_subj="maldet alert from $(hostname)"
# The destination addresses for email alerts
# [ values are comma (,) spaced ]
# Ignore e-mail alerts for reports in which all hits have been cleaned.
# This is ideal on very busy servers where cleaned hits can drown out
# other more actionable reports.
# [ QUARANTINE OPTIONS ]
# The default quarantine action for malware hits
# [0 = alert only, 1 = move to quarantine & alert]
# Try to clean string based malware injections
# [NOTE: quar_hits=1 required]
# [0 = disabled, 1 = clean]
# The default suspend action for users wih hits
# Cpanel suspend or set shell /bin/false on non-Cpanel
# [NOTE: quar_hits=1 required]
# [0 = disabled, 1 = suspend account]
# [ SCAN OPTIONS ]
# [ 0 = disabled, 1 = enabled; enabled by default ]
And these are the most important settings to be configured:
email_subj="Malware alerts for $HOSTNAME - $(date +%Y-%m-%d)"
The next task is to install ClamAV and have LMD use it as the antivirus engine. To install ClamAV, you will need to add a repository to your system. Create a repo file at /etc/yum.repos.d called dag.repo.
Then copy the following into dag.repo.
name=Dag RPM Repository for Red Hat Enterprise Linux
Once you’re done setting up the new repository, you can install clamd using yum.
yum update && yum install clamd
You’re now done with the installation process, and can use LMD with ClamAV to detect malware on your server. If this guide was helpful to you, kindly share it with others who may also be interested.
Here are a few commands you may find useful:
To update the LMD malware detection signatures:
To update the LMD malware version:
To scan all files located in a specific directory:
maldet -a /path
To put all detected threats into quarantine:
maldet -q SCANID
To restore files from quarantine:
maldet –s SCANID