سختسازی سرور لینوکس: چکلیست تولیدی
یک سرور لینوکس سختشده سطح حمله را بهطور قابل توجهی کاهش میدهد. این چکلیستی است که روی هر سرور تولیدی اعمال میکنم.
۱. سختسازی SSH
BASH
# /etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AllowUsers deployuser adminuser
MaxAuthTries 3۲. فایروال با UFW
BASH
ufw default deny incoming
ufw default allow outgoing
ufw allow from 10.0.0.0/8 to any port 22
ufw allow 443/tcp
ufw enable۳. Fail2Ban
BASH
apt install fail2ban
# /etc/fail2ban/jail.local
[sshd]
enabled = true
maxretry = 3
bantime = 3600۴. بهروزرسانیهای امنیتی خودکار
BASH
apt install unattended-upgrades
dpkg-reconfigure unattended-upgrades۵. سختسازی هسته (sysctl)
BASH
# /etc/sysctl.d/99-hardening.conf
net.ipv4.ip_forward = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.log_martians = 1
kernel.randomize_va_space = 2
kernel.dmesg_restrict = 1۶. لاگگیری Audit
BASH
apt install auditd
# /etc/audit/rules.d/hardening.rules
-w /etc/passwd -p wa -k identity
-w /etc/sudoers -p wa -k sudo
-a always,exit -F arch=b64 -S execve -k exec۷. بررسی انطباق CIS
BASH
apt install lynis
lynis audit systemهدف: امتیاز ۷۰+ (سرورهای تولیدی باید به ۸۰+ برسند).
