Last active
January 7, 2026 11:00
-
-
Save LucaBazzea/d6f6e25f67678cd5916cdbad2909798e to your computer and use it in GitHub Desktop.
Ubuntu server configuration and hardening script
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
| # Packages remove | |
| apt purge \ | |
| ed nano \ | |
| x11-common xauth libx11-* gdm3 lightdm \ | |
| apache2 \ | |
| exim4 postfix sendmail \ | |
| perl python2 python3-minimal ruby \ | |
| snapd \ | |
| cloud-init \ | |
| avahi-daemon \ | |
| cups \ | |
| ModemManager | |
| # Update | |
| apt update | |
| apt upgrade -y | |
| # Clean up | |
| apt autoremove --purge | |
| apt clean | |
| apt autoclean | |
| # Packages install | |
| apt install \ | |
| ca-certificates \ | |
| curl \ | |
| python3 \ | |
| fastfetch \ | |
| wget | |
| # Firewall | |
| ufw allow ssh | |
| ufw allow http | |
| ufw allow https | |
| ufw enable | |
| ufw status verbose | |
| # Disable redundant services | |
| systemctl disable --now multipathd.service | |
| systemctl disable --now multipathd.socket | |
| systemctl stop multipathd.socket | |
| # Docker | |
| apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1) | |
| install -m 0755 -d /etc/apt/keyrings | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
| chmod a+r /etc/apt/keyrings/docker.asc | |
| sudo tee /etc/apt/sources.list.d/docker.sources <<EOF | |
| Types: deb | |
| URIs: https://download.docker.com/linux/ubuntu | |
| Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") | |
| Components: stable | |
| Signed-By: /etc/apt/keyrings/docker.asc | |
| EOF | |
| apt update | |
| apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
| docker run hello-world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment