Skip to content

Instantly share code, notes, and snippets.

@diogoalexsmachado
Created July 28, 2025 22:27
Show Gist options
  • Select an option

  • Save diogoalexsmachado/86c98ff2bef28868b410c88c9818fe59 to your computer and use it in GitHub Desktop.

Select an option

Save diogoalexsmachado/86c98ff2bef28868b410c88c9818fe59 to your computer and use it in GitHub Desktop.

๐Ÿš€ CloudPanel VPS Auto-Setup Script

This script automates the installation of CloudPanel on a fresh Ubuntu 22.04 VPS. It configures system basics, security (UFW + Fail2Ban), and installs CloudPanel in minutes.


๐Ÿ”— Access CloudPanel

Once installed, access the CloudPanel admin panel via:

https://:8443

โš ๏ธ Cloudflare does not proxy port 8443. You must access CloudPanel directly or secure it using one of the methods below.


๐Ÿ”’ Security Tips

  • Restrict Admin Panel Access (port 8443) by allowing only your IP:
ufw allow from YOUR.IP.ADDRESS to any port 8443

Use SSH tunneling for secure access:

ssh -L 8443:localhost:8443 root@your-vps-ip\

Then open in your browser: https://localhost:8443

๐Ÿงฉ Optional Enhancements

  • Cloudflare DNS and SSL provisioning via API
  • Auto-subdomain creation with Letโ€™s Encrypt support
  • Lock CloudPanel access to specific IPs or countries
  • Add monitoring tools like Netdata or Prometheus

๐Ÿ™‹ Support

  • For help or feature requests:
  • Open an issue in this repository
  • Request Cloudflare integration assistance
  • Ask for automation or hardening scripts
#!/bin/bash
# cloudpanel-setup.sh
# Automates the installation of CloudPanel on a fresh Ubuntu 22.04 VPS.
# Includes: system updates, firewall setup, fail2ban, CloudPanel install.
# Author: [Your Name or GitHub Handle]
# https://www.cloudpanel.io/
set -e
echo "โ–ถ๏ธ Updating system..."
apt update && apt upgrade -y
echo "โ–ถ๏ธ Installing essential packages..."
apt install -y curl wget sudo ufw fail2ban software-properties-common
echo "โ–ถ๏ธ Setting timezone to UTC..."
timedatectl set-timezone UTC
echo "โ–ถ๏ธ Enabling UFW firewall and allowing essential ports..."
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow http
ufw allow https
ufw allow 8443/tcp
ufw --force enable
echo "โ–ถ๏ธ Installing CloudPanel..."
wget -O installer.sh https://installer.cloudpanel.io/ce/v2/install.sh
chmod +x installer.sh
sudo bash installer.sh
echo "โ–ถ๏ธ Configuring Fail2Ban for SSH brute-force protection..."
cat > /etc/fail2ban/jail.local <<EOF
[sshd]
enabled = true
port = ssh
logpath = %(sshd_log)s
backend = systemd
maxretry = 5
bantime = 3600
EOF
systemctl enable fail2ban
systemctl restart fail2ban
IP=$(curl -s https://ipinfo.io/ip)
echo ""
echo "โœ… CloudPanel installation complete!"
echo "======================================="
echo "๐Ÿ”— Admin Panel URL: https://$IP:8443"
echo "โš ๏ธ Port 8443 is NOT proxied by Cloudflare."
echo "๐Ÿ”’ Secure CloudPanel with IP whitelisting or SSH tunneling."
echo "======================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment