您好,登錄后才能下訂單哦!
在Ubuntu root權(quán)限下進(jìn)行系統(tǒng)安全加固,可以通過編寫自動化腳本來實(shí)現(xiàn)
apt-get update
apt-get upgrade -y
systemctl disable --now cron.daily.service
systemctl disable --now cron.weekly.service
systemctl disable --now cron.monthly.service
apt-get autoremove -y
apt-get autoremove --purge $(dpkg --list | grep linux-image | grep -v $(uname -r)) -y
chage -d 9999 root
passwd -d root
sed -i 's/^PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
sed -i 's/^Port 22/Port 2222/' /etc/ssh/sshd_config
apt-get install fail2ban -y
/etc/fail2ban/jail.d/sshd.conf
文件,設(shè)置以下參數(shù):[sshd]
enabled = true
filter = sshd
logpath = /var/log/auth.log
action = %(action_mwl)s
your_script[script=/path/to/your/script.sh]
maxretry = 5
findtime = 600
bantime = 600
/path/to/your/script.sh
,用于封禁IP地址:#!/bin/bash
ip=$1
ban_time=600
/usr/bin/iptables -A INPUT -s $ip -j DROP
echo "$ip has been banned for $ban_time seconds." >> /var/log/ban_ip.log
chmod +x /path/to/your/script.sh
systemctl restart fail2ban
以上腳本僅為示例,實(shí)際應(yīng)用中可能需要根據(jù)具體需求進(jìn)行調(diào)整。在執(zhí)行任何更改之前,請確保備份重要數(shù)據(jù)并充分了解每個(gè)命令的作用。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。