Skip to content

Instantly share code, notes, and snippets.

@eminkel
Created November 18, 2024 22:45
Show Gist options
  • Save eminkel/41064a5d7062465a5d59cd4efff45afe to your computer and use it in GitHub Desktop.
Save eminkel/41064a5d7062465a5d59cd4efff45afe to your computer and use it in GitHub Desktop.
Server provision security script
#!/bin/bash
# Update and upgrade
apt-get update && apt-get upgrade -y
# Install common utilities
apt-get install -y curl wget git docker fail2ban net-tools
# Setup fail2ban
cp
# Setup firewall
ufw default deny incoming
ufw allow 22
ufw allow 80
ufw allow 443
# Allow from internal ip range?
# ufw allow from 192.168.0.1/24
ufw enable
# Create a default user
USER_NAME=deploy
adduser --disabled-password --gecos "" $USER_NAME
usermod -aG sudo docker deploy
# Setup SSH for new user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment