One-command solution to automatically mount Hetzner Storage Box on Linux systems with zero manual configuration. Now supports multiple distributions, non-interactive mode, and enhanced security.
curl -fsSL https://raw.githubusercontent.com/Automations-Project/Hetzner-Shells/main/Storage/Mount-Storage-Box.sh | sudo bash -s
wget https://raw.githubusercontent.com/Automations-Project/Hetzner-Shells/main/Storage/Mount-Storage-Box.sh
chmod +x Mount-Storage-Box.sh
sudo ./Mount-Storage-Box.sh
# Simply run:
curl -fsSL https://raw.githubusercontent.com/Automations-Project/Hetzner-Shells/main/Storage/Mount-Storage-Box.sh | sudo bash -s
# Just for testing (Dry Run):
curl -fsSL https://raw.githubusercontent.com/Automations-Project/Hetzner-Shells/main/Storage/Mount-Storage-Box.sh | sudo bash -s -- --dry-run
# Non-interactive:
curl -fsSL https://raw.githubusercontent.com/Automations-Project/Hetzner-Shells/main/Storage/Mount-Storage-Box.sh | sudo bash -s -- --non-interactive --username u123456 --password-file /secure/pass.txt --mount-point /mnt/hetzner-storage --mount-method systemd
Feature | Description |
---|---|
π Auto-Detection | Detects distribution (Ubuntu, Debian, RHEL), version, architecture (ARM64/x86_64), package/service managers, and system compatibility |
π§ Repository Fixes | Automatically fixes ARM64 repository configuration for ports.ubuntu.com (Ubuntu-specific) |
π¦ Package Management | Installs cifs-utils , keyutils , and required kernel modules using apt/yum/dnf/zypper |
π Security First | Creates secure credentials file with 0600 permissions; supports password files for non-interactive use; validates mount points; signal handling (INT/TERM) for graceful cleanup; warnings for insecure CLI passwords |
ποΈ Smart Mounting | Tests SMB versions (3.1.1 to 1.0), validates write access, handles existing mounts; centralized command building for efficiency |
βοΈ Persistent Setup | Optional /etc/fstab or systemd mount unit integration with automount support |
ποΈ Non-Interactive Mode | Run without prompts using flags (e.g., --username , --password-file , --mount-point ); dry-run (--dry-run ) and verbose (--verbose ) options |
π Comprehensive Logging | Full operation logging with timestamps, colored output, and ANSI stripping for clean logs |
π‘οΈ Error Handling | Strict mode (set -eEuo pipefail ), traps for errors/signals, retries (up to 3), automatic backups, rollback capabilities, specific failure diagnostics |
β‘ Optimizations | Performance tuning (rsize/wsize for Hetzner network); conditional skips for existing setups; spinner for non-blocking operations |
- β Ubuntu 20.04+ LTS (ARM64/x86_64)
- β Debian 10+ (x86_64/ARM64 where supported)
- β RHEL/CentOS 7+ (x86_64)
- β Fedora (via DNF)
- β openSUSE (via Zypper)
- β Hetzner Cloud VPS (all architectures)
- β Other Linux systems with compatible package managers
Before (Manual Process):
# Multiple commands, distro/arch-specific issues
sudo nano /etc/apt/sources.list # Fix ARM64 repositories
sudo apt update # Often fails with 404s
sudo apt install cifs-utils # "Package not found" errors
sudo nano /etc/cifs-credentials.txt # Manual credential creation
sudo chmod 0600 /etc/cifs-credentials.txt
sudo mkdir /mnt/hetzner-storage
sudo mount.cifs //server/path /mnt/... # Complex mount options
sudo nano /etc/fstab # Manual fstab editing
After (This Script):
# Single command - everything automated
curl -fsSL https://raw.githubusercontent.com/Automations-Project/Hetzner-Shells/main/Storage/Mount-Storage-Box.sh | sudo bash
Non-interactive example:
sudo ./Mount-Storage-Box.sh --non-interactive --username u123456 --password-file /secure/pass.txt --mount-point /data/storage --mount-method systemd
- Argument Parsing & Welcome - Handles flags, shows banner
- System Analysis - Detects distro, arch, managers, network/DNS
- Preparation - Fixes repos (ARM64), updates packages, installs dependencies
- Configuration - Gets credentials (interactive or args), mount options with validation
- Mount Testing - Negotiates SMB, mounts with retries, verifies access
- Persistence - Configures fstab/systemd based on choice/method
- Verification & Tips - Shows stats, commands, performance advice
Interactive:
sudo ./Mount-Storage-Box.sh
Non-Interactive with Password File:
sudo ./Mount-Storage-Box.sh --non-interactive --username u123456-sub1 --password-file /secure/pass.txt --verbose
Dry-Run (Preview Changes):
sudo ./Mount-Storage-Box.sh --dry-run --username u123456 --password-file /secure/pass.txt
Custom Options:
sudo ./Mount-Storage-Box.sh --non-interactive --username u123456 --password-file /secure/pass.txt --mount-point /mnt/custom --uid 1000 --gid 1000 --no-tuning --mount-method fstab
Full Help:
sudo ./Mount-Storage-Box.sh --help
Hetzner-Shells/
βββ Storage/
β βββ Mount-Storage-Box.sh # Main auto-mount script (v1.0.2)
βββ README.md # This file
βββ LICENSE # MIT License
βββ TESTING.md # Testing & deployment guide
βββ test-logs.txt # Example test output
- Credentials: Stored in
/etc/cifs-credentials.txt
with root:0600 ownership. Use--password-file
for automation to avoid CLI exposure. - Validation: Mount points sanitized against dangerous paths (e.g., /etc, /boot); username regex-checked.
- Signals: Handles Ctrl+C (INT) and TERM for cleanup (unmount, temp file removal).
- Recommendations: On production, consider encrypting credentials (e.g., via
gpg
) or using secrets managers. Run in isolated environments. - Audits: Script passes ShellCheck; no known vulnerabilities.
- Performance: Hetzner-specific options (seal, rsize=130048, cache=loose) for 300-800 MB/s throughput.
- Efficiency: Skips redundant steps (e.g., existing packages); non-blocking spinners; conditional network checks in dry-run.
- Maintainability: Modular functions, readonly globals, centralized logging/error handling.
- Testing: Use
--dry-run
for safe previews; full tests in TESTING.md.
Contributions welcome! Submit PRs for new distros, features, or fixes. Run shellcheck Mount-Storage-Box.sh
before submitting.
MIT License - see LICENSE for details.
- π Documentation: TESTING.md for tests; Hetzner Docs
- π Issues: GitHub Issues
- π‘ Features: Suggest via Issues
- π§ Contact: Open an issue
Star this repo if it helps! Contributions and feedback drive improvements.
Get Started β’ Features β’ Security β’ Hetzner Docs