How To Install sshguard on CentOS 8

sshguard is Protects hosts from brute-force attacks against SSH and other services

Introduction

In this tutorial we learn how to install sshguard on CentOS 8.

What is sshguard

Sshguard protects hosts from brute-force attacks against SSH and other services. It aggregates system logs and blocks repeat offenders using one of several firewall backends. Sshguard can read log messages from standard input or monitor one or more log files. Log messages are parsed, line-by-line, for recognized patterns. If an attack, such as several login failures within a few seconds, is detected, the offending IP is blocked. Offenders are unblocked after a set interval, but can be semi-permanently banned using the blacklist option.

We can use yum or dnf to install sshguard on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install sshguard.

Install sshguard on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install sshguard using dnf by running the following command:

sudo dnf -y install sshguard

Install sshguard on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install sshguard using yum by running the following command:

sudo yum -y install sshguard

How To Uninstall sshguard on CentOS 8

To uninstall only the sshguard package we can use the following command:

sudo dnf remove sshguard

sshguard Package Contents on CentOS 8

/etc/sshguard.whitelist
/usr/lib/.build-id
/usr/lib/.build-id/2c
/usr/lib/.build-id/2c/3ccefb1ed4396cf6c92fd9278e34270401e903
/usr/lib/.build-id/67
/usr/lib/.build-id/67/4e612608cb94576fd9cae6e69f2dc1e8fe02b2
/usr/lib/.build-id/cf
/usr/lib/.build-id/cf/a1176da7844a11e4a06cf431c7dc6f573e8e27
/usr/lib/systemd/system/sshguard.service
/usr/libexec/sshguard
/usr/libexec/sshguard/sshg-blocker
/usr/libexec/sshguard/sshg-fw-firewalld
/usr/libexec/sshguard/sshg-fw-hosts
/usr/libexec/sshguard/sshg-fw-ipfilter
/usr/libexec/sshguard/sshg-fw-ipfw
/usr/libexec/sshguard/sshg-fw-ipset
/usr/libexec/sshguard/sshg-fw-iptables
/usr/libexec/sshguard/sshg-fw-nft-sets
/usr/libexec/sshguard/sshg-fw-null
/usr/libexec/sshguard/sshg-fw-pf
/usr/libexec/sshguard/sshg-logtail
/usr/libexec/sshguard/sshg-parser
/usr/sbin/sshguard
/usr/share/doc/sshguard
/usr/share/doc/sshguard/CONTRIBUTING.rst
/usr/share/doc/sshguard/README.rst
/usr/share/doc/sshguard/examples
/usr/share/doc/sshguard/examples/sshguard.conf.sample
/usr/share/doc/sshguard/examples/whitelistfile.example
/usr/share/licenses/sshguard
/usr/share/licenses/sshguard/COPYING
/usr/share/man/man7/sshguard-setup.7.gz
/usr/share/man/man8/sshguard.8.gz
/var/lib/sshguard

References

Summary

In this tutorial we learn how to install sshguard on CentOS 8 using yum and dnf.