Environment:
- Windows Server 2019
- Hyper-V
- Ubuntu Server 20.04.3 LTS.
Configurations:
1. After Ubuntu Server is installed on a VM (with a clean and minimum installation without any preloaded packages), set up Docker and OpenSSH.
# Install OpenSSH
apt update -y
apt upgrade -y
apt install openssh-server -y
# Check SSH Status
systemctl status ssh
# Allow ssh over UFW firewall
ufw allow ssh
2. Enable UFW, check status, and configure rules.
# Enable UFW
ufw enable
# Check status and rules
ufw status
# Check status and make results numbered
ufw status numbered
# Disable UFW
ufw disable
# Block IP
ufw deny from IP-Address
# Block by subnet
ufw deny from IP/CIDR
# Block connections on interface
ufw deny in on eth0 from IP-Address
# Allow commands:
ufw allow from IP-Address
ufw allow in on eth0 from IP-Address
# Delete rule
ufw status numbered
ufw delete [number]
# Allow by protocol
ufw allow from IP-Address proto tcp to any port 22
ufw allow from IP/CIDR proto tcp to any port 22
ufw allow proto tcp from any to any port 80,443
3. Disable ipv6 on Ubuntu Server.
# Add
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
# to file /etc/sysctl.conf
4. Reduce Ubuntu shutdown time.
# Edit /etc/systemd/system.conf and uncomment DefaultTimeoutStopSec=90s and set it to a desired value
DefaultTimeoutStopSec=15s
5. Install Docker
# Remove existing Docker installations, if any
apt remove docker docker-engine docker.io containerd runc
# Install using the repository
apt update -y
apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Set up stable repository
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker engine
apt update -y
apt install -y docker-ce docker-ce-cli containerd.io
# Verify that Docker Engine is correctly installed
docker version