A robust, idempotent bash script to quickly setup a fresh & secure Ubuntu 24.04 VPS with tailscale.
- Fully automated and idempotent (safe to run multiple times).
- System update and package installation.
- Configurable unprivileged user creation with sudo access.
- Secure SSH hardening (disables root login, password auth).
- UFW firewall configuration with safe defaults (Tailscale access).
- Tailscale installation.
- A fresh Ubuntu VPS.
- Logged in as root.
You can run the script with a single command from your VPS as root:
curl -fsSL https://raw.githubusercontent.com/vassista/vps-setup/main/setup-vps.sh | bashWarning
Please review the script before running it directly to understand the configuration changes it makes.
To customize the script (e.g., change the username), clone the repository, edit setup-vps.sh, and run it locally:
git clone https://github.com/vassista/vps-setup.git
cd vps-setup
# Edit setup-vps.sh to change USERNAME="your_username"
./setup-vps.shThe setup process is orchestrated by setup-vps.sh and broken down into modular scripts inside the scripts/ directory:
update.sh: Updates the system usingapt.packages.sh: Installs necessary utilities.user.sh: Creates an unprivileged user and sets up SSH keys.ssh.sh: Hardens the SSH daemon configuration.tailscale.sh: Installs Tailscale.firewall.sh: Configures UFW.verify.sh: Prints verification information.
- SSH Access: If you lose SSH access, ensure that the authorized keys were properly copied to the new user. You may need to access your VPS through the provider's web console.
- Tailscale: The script installs Tailscale but requires manual authentication. Run
sudo tailscale up --sshafter the script completes to connect the VPS to your tailnet.