Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/tests/ubuntu_26.04_verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Ubuntu 26.04 LTS Verification Report

**Date:** 2026-06-18
**Target OS:** Ubuntu 26.04 LTS (Resolute Raccoon) - Linux 7.0.0-22-generic x86_64
**Script Version:** v0.80.7
**Environment:** Vultr Commercial Cloud VPS

## Executive Summary

Comprehensive testing of `du_setup.sh` on a fresh installation of Ubuntu 26.04 LTS was performed successfully. All base services, package management functions, security hardening measures, and optional software installations operated without errors, proving full compatibility with the latest LTS release.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 305 Warning test

Expected: 80; Actual: 305
Comment thread
buildplan marked this conversation as resolved.
Dismissed

## Execution Logs Overview

- **Script Validation:** SHA256 checksum verified (`du_setup.sh: OK`).
- **OS Detection:** Script correctly recognized Ubuntu 26.04 LTS and proceeded via the updated validations.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 107 Warning test

Expected: 80; Actual: 107
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- **Package Management:** `apt` and `dpkg` successfully installed all essential tools (vim, chrony, fail2ban, tailscale, docker, etc.) with no dependency issues.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 161 Warning test

Expected: 80; Actual: 161
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- **System Service Overrides:** Properly removed `systemd-timesyncd` in favor of `chrony` without disrupting the provisioning process.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 134 Warning test

Expected: 80; Actual: 134
Comment thread
buildplan marked this conversation as resolved.
Dismissed

## Feature Verification Checklist

### 1. User Management

- [x] Sudo user (`admin`) successfully created.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] SSH public key injection succeeded.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] Custom `.bashrc` deployed for the user.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed

### 2. Networking & Firewall (UFW)

- [x] UFW activated and persisted through reboot.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] Custom SSH port (`5555/tcp`) allowed, and default `22/tcp` safely closed.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] IPv4 & IPv6 firewall rules accurately loaded.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] Tailscale UDP 41641 allowed.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed

### 3. Intrusion Prevention (Fail2Ban)

- [x] Fail2Ban successfully compiled and deployed active jails.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] `sshd` and `ufw-probes` jails verified active.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] **Live Defense Verified:** 4 malicious IPs actively banned by the `ufw-probes` jail during the immediate post-boot testing phase.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 135 Warning test

Expected: 80; Actual: 135

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
Comment thread
buildplan marked this conversation as resolved.
Dismissed

### 4. Hardening (Sysctl & SSH)

- [x] Root SSH login successfully disabled.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] Key-based authentication successfully enforced.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] SSH listener correctly moved to port `5555`.

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] Kernel parameters validated post-reboot (`fs.protected_hardlinks = 1`, `kernel.yama.ptrace_scope = 1`).

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 109 Warning test

Expected: 80; Actual: 109

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
Comment thread
buildplan marked this conversation as resolved.
Dismissed

### 5. Services & Addons

- [x] **Time Sync (Chrony):** Successfully synchronized with canonical NTP servers (`ntp-nts-2.ps5.canonical.com`).

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 115 Warning test

Expected: 80; Actual: 115

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] **Docker:** Engine cleanly installed via official repositories, and execution via the `admin` user group succeeded without `sudo` (`docker ps`).

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 150 Warning test

Expected: 80; Actual: 150

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] **Tailscale:** Package loaded successfully from the stable repository (daemon active and ready for auth).

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 111 Warning test

Expected: 80; Actual: 111

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] **Swap Memory:** Swap correctly disabled, resized, and dynamically mounted as a 2.3Gi file.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 97 Warning test

Expected: 80; Actual: 97

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
Comment thread
buildplan marked this conversation as resolved.
Dismissed
- [x] **Provider Cleanup:** Vultr commercial VPS successfully audited; default provisioning user `linuxuser` safely removed.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 124 Warning test

Expected: 80; Actual: 124

Check warning

Code scanning / Remark-lint (reported by Codacy)

[no-undefined-references] Found reference to undefined definition Warning test

[no-undefined-references] Found reference to undefined definition
Comment thread
buildplan marked this conversation as resolved.
Dismissed
Comment thread
buildplan marked this conversation as resolved.
Dismissed

## Conclusion

The `du_setup.sh` script is 100% stable on Ubuntu 26.04 LTS. The underlying shifts in the new LTS release do not negatively impact any of the standard POSIX shell tools or package managers (`apt`/`dpkg`) that the script orchestrates. All configurations persist flawlessly across system reboots. No further logic updates are required beyond the OS version-check modifications already committed.

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 393 Warning test

Expected: 80; Actual: 393
Comment thread
buildplan marked this conversation as resolved.
Dismissed
2 changes: 1 addition & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@d43360362776a6789b47b99ae8973510854e2d3d
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
- name: Install ShellCheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Run Shellcheck
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Debian & Ubuntu Server Setup & Hardening Script

[![Debian Compatibility](https://img.shields.io/badge/Compatibility–Debian%2012%7C13-%23A81D33?style=flat&labelColor=555&logo=debian&logoColor=white)](https://www.debian.org/releases/)
[![Ubuntu Compatibility](https://img.shields.io/badge/Compatibility–Ubuntu%2022.04%7C24.04-%23E95420?style=flat&labelColor=555&logo=ubuntu&logoColor=white)](https://ubuntu.com/download/server)
[![Ubuntu Compatibility](https://img.shields.io/badge/Compatibility–Ubuntu%2022.04%7C24.04%7C26.04-%23E95420?style=flat&labelColor=555&logo=ubuntu&logoColor=white)](https://ubuntu.com/download/server)
[![Shell Script Linter](https://github.com/buildplan/du_setup/actions/workflows/lint.yml/badge.svg)](https://github.com/buildplan/du_setup/actions/workflows/lint.yml)
[![Codacy Security Scan](https://github.com/buildplan/du_setup/actions/workflows/codacy.yml/badge.svg?branch=main)](https://github.com/buildplan/du_setup/actions/workflows/codacy.yml)

-----

**Version:** v0.80.7
**Version:** v0.80.8

**Last Updated:** 2026-05-18
**Last Updated:** 2026-06-18

**Compatible With:**

* Debian 12, 13
* Ubuntu 20.04, 22.04, 24.04 (24.10 & 25.04 experimental)
* Ubuntu 20.04, 22.04, 24.04, 26.04 (24.10, 25.04 & 25.10 experimental)

## Overview

Expand Down Expand Up @@ -88,12 +88,12 @@

Compare the output hash to the one below. They must match exactly.

`637bd1835738deb5f525ed98f07566dc55331275139c7778fe79eb2f375c2091`
`a8d1c0e63c6a37ce103d4520312c9404f3bee713cfdca9aab06086494cb9c09a`

Or echo the hash to check, it should output: `du_setup.sh: OK`

```bash
echo 637bd1835738deb5f525ed98f07566dc55331275139c7778fe79eb2f375c2091 du_setup.sh | sha256sum --check
echo a8d1c0e63c6a37ce103d4520312c9404f3bee713cfdca9aab06086494cb9c09a du_setup.sh | sha256sum --check

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 101 Warning

Expected: 80; Actual: 101
Comment thread
buildplan marked this conversation as resolved.
Dismissed
```

### 3. Run the Script
Expand Down Expand Up @@ -135,7 +135,7 @@
| **SSH Hardening and Rollback** | Disables root login, configures key-based authentication, sets custom SSH port, and supports rollback of SSH configuration if connectivity fails. |
| **Firewall Setup** | Configures UFW to deny incoming traffic by default, allowing specific user-defined ports. |
| **Fail2Ban/CrowdSec Setup** | Configures Fail2Ban or CrowdSec to monitor SSH and UFW logs, blocking suspicious IPs. |
| **2FA Setup** | Configures TOTP, shows QR code in the terminal to be scanned with any OTP app and inculdes rollback in case it any issues with setup. |
| **2FA Setup** | Configures TOTP, shows QR code in the terminal to be scanned with any OTP app and includes rollback in case it any issues with setup. |

Check warning

Code scanning / Markdownlint (reported by Codacy)

Expected: 80; Actual: 153 Warning

Expected: 80; Actual: 153
Comment thread
buildplan marked this conversation as resolved.
Dismissed
| **Auto-Updates Setup** | Enables and configures `unattended-upgrades` for automatic security patches. |
| **Time Sync Setup** | Ensures `chrony` is active for accurate network time synchronization. |
| **Kernel and Sysctl Hardening** | Optional improvements to kernel parameters to mitigate common network attacks and improve system hardening. |
Expand Down Expand Up @@ -184,7 +184,7 @@
* **Fail2Ban Status**: `sudo fail2ban-client status sshd`
* **Swap Status**: `sudo swapon --show && free -h`
* **Hostname**: `hostnamectl`
* **Kernal Hardening** (if configured):
* **Kernel Hardening** (if configured):
* Check the conf file: `sudo cat /etc/sysctl.d/99-du-hardening.conf`
* Checks the live value of a few key parameters that script sets: `sudo sysctl fs.protected_hardlinks kernel.yama.ptrace_scope net.ipv4.tcp_syncookies`
* **Docker Status** (if installed): `docker ps`
Expand All @@ -209,7 +209,7 @@
## Tested On

* Debian 12, 13
* Ubuntu 22.04, 24.04 - 24.10 & 25.04 (experimental)
* Ubuntu 22.04, 24.04, 26.04 - 24.10, 25.04 & 25.10 (experimental)
* Cloud providers: DigitalOcean, Oracle Cloud, OVH Cloud, Hetzner, Netcup
* Backup destinations: Hetzner Storage Box (SSH, port 23), custom SSH servers
* Tailscale: Standard network, custom self-hosted servers
Expand Down
29 changes: 16 additions & 13 deletions du_setup.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

# Debian and Ubuntu Server Hardening Interactive Script
# Version: 0.80.7 | 2026-05-18
# Version: 0.80.8 | 2026-06-18
# Changelog:
# - v0.80.8: Tested and verified compatibility with Ubuntu 26.04 LTS.
# Gracefully handle swap creation failures to prevent script aborts, ensuring setup carries on.
# - v0.80.7: Choose between tailscale/netbird or both. Improve SSH hardening flow to skip redundant checks if port is unchanged.
# - v0.80.6: Fix Docker config, private Docker network to use a private ip range.
# - v0.80.5: Fixed a crash in timezone validation by checking for files (-f) instead of directories.
Expand Down Expand Up @@ -274,7 +276,7 @@ print_header() {
printf '%s\n' "${CYAN}╔═════════════════════════════════════════════════════════════════╗${NC}"
printf '%s\n' "${CYAN}║ ║${NC}"
printf '%s\n' "${CYAN}║ DEBIAN/UBUNTU SERVER SETUP AND HARDENING SCRIPT ║${NC}"
printf '%s\n' "${CYAN}║ v0.80.7 | 2026-05-18 ║${NC}"
printf '%s\n' "${CYAN}║ v0.80.8 | 2026-06-18 ║${NC}"
printf '%s\n' "${CYAN}║ ║${NC}"
printf '%s\n' "${CYAN}╚═════════════════════════════════════════════════════════════════╝${NC}"
printf '\n'
Expand Down Expand Up @@ -2807,10 +2809,10 @@ check_system() {
source /etc/os-release
ID=${ID:-unknown} # Populate global ID variable
if [[ $ID == "debian" && $VERSION_ID =~ ^(12|13)$ ]] || \
[[ $ID == "ubuntu" && $VERSION_ID =~ ^(20.04|22.04|24.04)$ ]]; then
[[ $ID == "ubuntu" && $VERSION_ID =~ ^(20.04|22.04|24.04|24.10|25.04|25.10|26.04)$ ]]; then
print_success "Compatible OS detected: $PRETTY_NAME"
else
print_warning "Script not tested on $PRETTY_NAME. This is for Debian 12/13 or Ubuntu 20.04/22.04/24.04 LTS."
print_warning "Script not tested on $PRETTY_NAME. This is for Debian 12/13 or Ubuntu 20.04-26.04."
if ! confirm "Continue anyway?"; then exit 1; fi
fi
else
Expand Down Expand Up @@ -5513,9 +5515,10 @@ configure_swap() {
done

print_info "Disabling existing swap file..."
swapoff "$existing_swap" || { print_error "Failed to disable swap file."; exit 1; }
swapoff "$existing_swap" || { print_error "Failed to disable swap file. Continuing without resizing."; return 0; }

print_info "Resizing swap file to $SWAP_SIZE..."
rm -f "$existing_swap"
# Try fallocate, fallback to dd
if ! fallocate -l "$SWAP_SIZE" "$existing_swap" 2>/dev/null; then
print_warning "fallocate failed. Using dd (slower)..."
Expand All @@ -5525,14 +5528,14 @@ configure_swap() {
if dd --version 2>&1 | grep -q "progress"; then dd_status="status=progress"; fi

if ! dd if=/dev/zero of="$existing_swap" bs=1M count="$REQUIRED_MB" $dd_status; then
print_error "Failed to create swap file with dd."
exit 1
print_error "Failed to create swap file with dd. Swap creation aborted."
return 0
fi
fi

if ! chmod 600 "$existing_swap" || ! mkswap "$existing_swap" >/dev/null || ! swapon "$existing_swap"; then
print_error "Failed to configure swap file."
exit 1
print_error "Failed to configure swap file. Swap configuration aborted."
return 0
fi
print_success "Swap file resized to $SWAP_SIZE."
else
Expand Down Expand Up @@ -5586,15 +5589,15 @@ configure_swap() {
local dd_status=""
if dd --version 2>&1 | grep -q "progress"; then dd_status="status=progress"; fi
if ! dd if=/dev/zero of=/swapfile bs=1M count="$REQUIRED_MB" $dd_status; then
print_error "Failed to create swap file."
print_error "Failed to create swap file. Swap creation aborted."
rm -f /swapfile || true
exit 1
return 0
fi
fi
if ! chmod 600 /swapfile || ! mkswap /swapfile >/dev/null || ! swapon /swapfile; then
print_error "Failed to enable swap file."
print_error "Failed to enable swap file. Swap configuration aborted."
rm -f /swapfile || true
exit 1
return 0
fi
if ! grep -q '^/swapfile ' /etc/fstab; then
echo '/swapfile none swap sw 0 0' >> /etc/fstab
Expand Down
2 changes: 1 addition & 1 deletion du_setup.sh.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
637bd1835738deb5f525ed98f07566dc55331275139c7778fe79eb2f375c2091 du_setup.sh
a8d1c0e63c6a37ce103d4520312c9404f3bee713cfdca9aab06086494cb9c09a du_setup.sh
Loading