vps-security-hardening

Automate VPS security hardening via SSH with user creation, firewall, and Fail2ban.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/2670044605/agent-skills-hub --skill vps-security-hardening
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vps-security-hardening
Source: https://github.com/2670044605/agent-skills-hub/tree/main/skills/registry/upstream/wlzh-skills/vps-security-hardening
Command: npx skills add https://github.com/2670044605/agent-skills-hub --skill vps-security-hardening

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sshpass, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Automates the end-to-end hardening of virtual private servers by applying best practices via SSH, reducing manual configuration and human error.

Core Features & Use Cases

  • Create a restricted sudo user and disable root password login.
  • SSH hardening for custom ports and key-based authentication.
  • Install and configure Fail2ban and UFW firewall.
  • Optional SSH login notifications and Docker awareness.
  • Supports Ubuntu 22.10-23.10 socket activation vs systemd, enabling reproducible provisioning.

Quick Start

Run the hardened script with your VPS IP, root password, new user, new user password, and the desired SSH port to perform the automated hardening workflow.

Frequently Asked Questions about vps-security-hardening

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate VPS security hardening for a new Ubuntu server?

Automate VPS security hardening by running an SSH-based script that creates a sudo user, changes the SSH port, configures UFW and Fail2ban, and enforces key-based authentication. This reduces manual configuration errors during new server provisioning.

Does VPS security hardening work with Ubuntu 22.10-23.10 SSH socket activation?

VPS security hardening supports Ubuntu 22.10-23.10 by addressing SSH socket activation versus systemd configurations. This ensures reproducible provisioning and correct SSH service behavior across those specific Ubuntu versions.

Can I disable root password login and set up key-based SSH authentication automatically?

Yes, the hardening workflow disables root password login and sets up key-based SSH authentication automatically. It creates a restricted sudo user and enforces non-standard SSH ports to secure remote access.

Do I need sshpass to configure UFW and Fail2ban remotely?

Yes, you need sshpass installed to run the automated hardening script, which connects to your VPS via SSH using the root password to install and configure UFW firewall and Fail2ban remotely.

What's the best way to configure a firewall and intrusion prevention on a fresh VPS?

Apply an automated hardening script to install and configure UFW for firewall rules and Fail2ban for intrusion prevention. This enforces best practices end-to-end, including optional login notifications and Docker awareness.

Why does my SSH connection break after changing the SSH port during hardening?

Changing the SSH port requires updating UFW firewall rules to allow traffic on the new non-standard port. The hardening script handles this configuration automatically, but manual changes without updating UFW will lock you out.