Created
February 18, 2026 16:27
-
-
Save dayio/f1b6f051de00d9551955c361ea8b6149 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #cloud-config | |
| # 1. System update | |
| package_update: true | |
| package_upgrade: true | |
| # 2. Package installation | |
| packages: | |
| - ca-certificates | |
| - curl | |
| - gnupg | |
| - ufw | |
| # 3. SSH configuration (Port 8899) | |
| write_files: | |
| - path: /etc/ssh/sshd_config.d/99-custom-port.conf | |
| permissions: '0644' | |
| content: | | |
| Port 8899 | |
| # 4. Run commands | |
| runcmd: | |
| # --- OFFICIAL DOCKER INSTALLATION --- | |
| - install -m 0755 -d /etc/apt/keyrings | |
| - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
| - chmod a+r /etc/apt/keyrings/docker.gpg | |
| - echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null | |
| - apt-get update | |
| - apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
| # --- FIREWALL CONFIGURATION (UFW) --- | |
| # IMPORTANT: We open the NEW SSH port (8899) before enabling the firewall | |
| - ufw allow 8899/tcp comment 'SSH Custom Port' | |
| # Web ports (Traefik) | |
| - ufw allow 80/tcp comment 'HTTP Traefik' | |
| - ufw allow 443/tcp comment 'HTTPS Traefik' | |
| # Docker Swarm ports (Cluster Internal) | |
| - ufw allow 2377/tcp comment 'Swarm Manager' | |
| - ufw allow 7946/tcp comment 'Swarm Node Comm TCP' | |
| - ufw allow 7946/udp comment 'Swarm Node Comm UDP' | |
| - ufw allow 4789/udp comment 'Swarm Overlay Network' | |
| # Enable firewall | |
| - ufw --force enable | |
| # --- APPLY SSH CONFIG --- | |
| # Restart SSH service to apply the new port 8899 | |
| - systemctl restart ssh | |
| # --- START DOCKER --- | |
| - systemctl enable docker | |
| - systemctl start docker | |
| final_message: "Server ready. SSH is listening on port 8899. Docker installed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment