Created
July 31, 2025 21:38
-
-
Save azizur/953805a7985128802f71d880650f112b to your computer and use it in GitHub Desktop.
cloud-config for setting a secure ubuntu seerver
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 | |
package_update: true | |
package_upgrade: true | |
packages: | |
- unattended-upgrades | |
- ufw | |
- fail2ban | |
- rkhunter | |
- apt-transport-https | |
- ca-certificates | |
- curl | |
- gnupg | |
- lsb-release | |
runcmd: | |
# Docker installation | |
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) 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 | |
- curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
- chmod +x /usr/local/bin/docker-compose | |
# Firewall setup | |
- ufw --force reset | |
- ufw default deny incoming | |
- ufw default allow outgoing | |
- ufw allow 2222/tcp | |
- ufw allow 80/tcp | |
- ufw allow 443/tcp | |
- echo "y" | ufw enable | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment