🔐 Automatically Install Fail2Ban with Smart Jail Detection on Your VPS (Script by Hosteons)

Here’s a complete WordPress blog post draft to promote your Fail2Ban Auto-Installer script from GitHub:


🔐 Automatically Install Fail2Ban with Smart Jail Detection on Your VPS (Script by Hosteons)

At Hosteons, we’re committed to making server security easier for everyone. Whether you’re running a small VPS or managing a fleet of Linux servers, protecting against brute-force attacks is critical.

That’s why we’ve created a Fail2Ban Auto-Installer Script that not only installs Fail2Ban but also auto-detects and enables jails for common services like SSHApache, and Nginx — all in one click.

👉 GitHub Repository:

https://github.com/hosteons/Fail2Ban-Auto-Installer-With-Jail


✅ Key Features

  • Installs Fail2Ban on UbuntuDebianAlmaLinux, and CentOS
  • Detects installed services (e.g., sshd, nginx, apache) and enables jails accordingly
  • Skips jails for services not found on the system
  • Handles log file paths intelligently based on distro
  • Verifies and restarts Fail2Ban only if configuration is valid
  • Smart checks if Fail2Ban is already installed
  • Minimal and safe — logs errors clearly

🧠 How It Works

When you run the script:

  1. It detects your Linux OS flavor.
  2. Installs Fail2Ban (if not already installed).
  3. Checks if apache, nginx, or sshd is active.
  4. Adds only the appropriate jails with correct log paths.
  5. Restarts Fail2Ban and confirms its status.
  6. Provides clear output so you know it’s working.

This ensures Fail2Ban doesn’t fail due to missing log files or services — a common issue in manual configurations.


📥 How to Use

  1. Download the script:
wget https://raw.githubusercontent.com/hosteons/Fail2Ban-Auto-Installer-With-Jail/main/fail2ban_auto_installer.sh
chmod +x fail2ban_auto_installer.sh
./fail2ban_auto_installer.sh
  1. That’s it. The script handles the rest!

🚀 Need a Secure VPS?

This script runs perfectly on our KVM VPS and Ryzen VPS plans. Visit hosteons.com to explore secure hosting powered by NVMe SSD and DDoS protection — with native support for IPv6, WireGuard VPN, and more.


🔗 Related Resources

How to Change Your SSH Port Safely on Any Linux Server (Ubuntu, Debian, CentOS, AlmaLinux)

Changing your SSH port is a simple yet powerful way to reduce brute-force login attempts and improve server security. To make this process easier, Hosteons offers a free Bash script that automatically handles the switch across all major Linux distributions — including firewalls and SELinux!


✅ Supported Operating Systems

  • Ubuntu 20.04 / 22.04
  • Debian 11 and above
  • CentOS 7 / 8
  • AlmaLinux 8 / 9

⚠️ Important Disclaimer

Changing your SSH port can lock you out if anything goes wrong.

Make sure you have console access such as VNC, IPMI, or KVM before using this script.


🔧 What the Script Does

  • Prompts until a valid SSH port is provided
  • Edits /etc/ssh/sshd_config to set the new port
  • Adds firewall rules for:
    • UFW (Ubuntu/Debian)
    • firewalld or iptables (CentOS/AlmaLinux)
  • Handles SELinux with semanage if needed
  • Restarts SSH service safely without reboot

🧰 How to Use the Script

  1. SSH into your VPS or server as root
  2. Run the following commands:
wget https://raw.githubusercontent.com/hosteons/SSH-Port-Changer-Script/main/ssh_port_changer.sh
chmod +x ssh_port_changer.sh
./ssh_port_changer.sh
  1. Enter your desired new SSH port when prompted

📦 Download from GitHub

Access the script and full documentation here:

👉 https://github.com/hosteons/SSH-Port-Changer-Script

How to update SSH Port in CentOS 7

Update SSH Port in CentOS 7

Here are few simple steps on how to update SSH Port in CentOS 7 VPS or Dedicated Server

Edit the SSHD configuration file :

nano -w /etc/ssh/sshd_config

(if nano is not installed use any other text editor or install it with yum -y install nano)

and change the Port number from 22 to any custom port you choose :

e.g. Port 18989

Make sure to even remove the # mark before Port

Save the config file

SELinux is enabled by default in CentOS 7 so you need to even inform SELinux to change the SSH Port else it won’t allow you to restart SSHD with new Port.

To run semanage for updating SSHD Port you nee to first install policycoreutils, install it with :

yum -y install policycoreutils-python

now update SeLinux policy to allow new port for SSH service. to do this, run below :

semanage port -a -t ssh_port_t -p tcp 18989

now you need to update Firewall policy to allow new SSH Port, to do this run below :

firewall-cmd –permanent –zone=public –add-port=18989/tcp
firewall-cmd –reload
systemctl restart sshd.service

SSHD Port is now updated, you can now connect to your new SSH Port: 18989

Upgrade to Kernel 4.x on CentOS 6/CentOS 7/ RHEL 7

Upgrade Linux Kernel to 4.x

Kernel 4.x is highly optimised and gives a lot of boost in performance to all Linux servers, here are few simple commands to upgrade your Kernel to 4.x on your CentOS 6 / CentOS 7 / RHEL 7 VPS (It will work with any KVM Based VPS like the ones provided by hosteons.com) or Dedicated server :

CentOS 6 / RHEL 6:

rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm

yum install yum-plugin-fastestmirror

yum –enablerepo=elrepo-kernel install kernel-ml

Now update /etc/grub.conf and make sure the new kernel 4.x is selected as default kernel and just reboot your VPS/Dedicated Server to use the new kernel.

CentOS 7/RHEL 7:

rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

yum install yum-plugin-fastestmirror

yum –enablerepo=elrepo-kernel install kernel-ml

Now update /etc/grub.conf and make sure the new kernel 4.x is selected as default kernel and just reboot your VPS/Dedicated Server to use the new kernel.