This article is translated from the Chinese original.
Docker
Non-mainland serverswget -qO- get.docker.com | bashorcurl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
Docker installation for mainland China serverscurl https://install.1panel.live/docker-install -o docker-install && sudo bash ./docker-install && rm -f ./docker-install
Check Docker versiondocker -v
Enable Docker on bootsudo systemctl enable docker
Uninstall Dockersudo apt-get purge docker-ce docker-ce-cli containerd.iosudo apt-get remove docker docker-enginesudo rm -rf /var/lib/dockersudo rm -rf /var/lib/containerd
Check Docker Compose versiondocker compose versionSSH
Change the default port 22 to 11451:
sudo sed -i 's/^#\\?Port 22.*/Port 11451/g' /etc/ssh/sshd_configRestart the sshd service:
sudo systemctl restart sshdfail2ban
Install fail2ban:
apt install fail2banConfigure fail2ban
The fail2ban configuration files are usually located in /etc/fail2ban/. The .conf files can be overridden by .local, so it is recommended to add a .local file instead of modifying the original configuration.
nano /etc/fail2ban/jail.localUse the following configuration:
[DEFAULT]# List of ignored IPs (whitelist)ignoreip = 127.0.0.1
# Allow ipv6allowipv6 = auto
# Log monitoring backend (gamin, polling, or auto)backend = systemd
# Per-service inspection settings, such as bantime, findtime, maxretry
[sshd]
# Enable this jail (true/false)enabled = true
# Name of the filter, corresponds to filter.d/sshd.conffilter = sshd
# SSH portport = ssh
# Action parametersaction = iptables[name=SSH, port=ssh, protocol=tcp]
# System login log filelogpath = /var/log/secure
# Ban duration, in secondsbantime = 86400
# If attempts exceed the limit within this period, the IP will be bannedfindtime = 86400
# Maximum number of retriesmaxretry = 3Press Ctrl+S to save and exit.
Enable fail2ban on boot:
sudo systemctl enable fail2banRestart fail2ban:
sudo systemctl restart fail2banCheck fail2ban status:
sudo systemctl status fail2banCheck all available jail statuses:
fail2ban-client status