To help you harden your Linux server quickly and securely, Hosteons has released a free, open-source hardening script that works across:
-
Ubuntu
-
Debian
-
CentOS
-
AlmaLinux
This script automates essential security steps such as updating your system, configuring SSH access, setting up a firewall, and running a basic audit.
Features
-
Automatically updates system packages
-
Prompts to change SSH port
-
Optionally disables root login
-
Option to create a new sudo-enabled user
-
Installs and enables Fail2Ban
-
Installs and runs a Lynis audit
-
Enables UFW (for Ubuntu/Debian) or firewalld (for CentOS/AlmaLinux)
-
Adjusts SELinux policies if active
How to Use
-
SSH into your VPS as root
-
Run the following commands:
curl -O https://raw.githubusercontent.com/hosteons/Linux-Hardening-Script/main/harden.sh
chmod +x harden.sh
./harden.sh
-
Follow the interactive prompts to configure your server securely
Important Notes
-
You must have console access (such as VNC or IPMI) in case SSH access is misconfigured
-
Use with caution on production servers
-
The script supports common distributions only (Ubuntu, Debian, CentOS, AlmaLinux)
GitHub Repository
You can view or contribute to the project at: