|
要彻底卸载阿里云轻量应用服务器上的阿里云盾(安骑士/Aegis),单靠手动 systemctl stop 或直接删除文件很容易因为其自我保护机制和守护进程而失败(正如你在文章评论中看到的 wait AliYunDun process exit fail)。 最稳妥、有效的方法是使用阿里云官方提供的卸载脚本。以下是具体的安全卸载步骤: 步骤一:使用官方脚本卸载请在服务器中以 root 权限依次执行以下命令: Bash
# 1. 下载并运行 Aegis 卸载脚本
wget http://update.aegis.aliyun.com/download/uninstall.sh
chmod +x uninstall.sh
./uninstall.sh
#2. 下载并运行 Quartz(云监控)卸载脚本
wget http://update.aegis.aliyun.com/download/quartz_uninstall.sh
chmod +x quartz_uninstall.sh
./quartz_uninstall.sh
步骤二:清理残留文件与进程脚本执行完毕后,部分进程或文件可能仍在缓存中,建议手动强制清理: Bash
# 1. 结束可能残存的阿里相关进程
pkill aliyun-service
pkill links-checker
pkill AgentWatch
# 2. 删除云盾及监控目录与文件
rm -rf /usr/local/aegis
rm -rf /etc/init.d/agentwatch
rm -rf /usr/sbin/aliyun-service
rm -rf /usr/sbin/aliyun-service.backup
rm -rf /usr/sbin/aliyun-assist-daemon
# 3. 检查是否有服务残留并清理(针对 systemd 系统)
systemctl disable aegis 2>/dev/null
rm -f /etc/systemd/system/aegis.service
systemctl daemon-reload
步骤三:屏蔽云盾 IP(可选)如果你不希望云盾后续自动连接阿里云的安全服务器接收指令,可以通过 iptables 封禁相关的 IP 段: Bash
iptables -I INPUT -s 140.205.201.0/28 -j DROP
iptables -I INPUT -s 140.205.201.16/29 -j DROP
iptables -I INPUT -s 140.205.201.32/28 -j DROP
iptables -I INPUT -s 140.205.225.192/29 -j DROP
iptables -I INPUT -s 140.205.225.200/30 -j DROP
iptables -I INPUT -s 140.205.225.184/29 -j DROP
常见问题:提示 "Operation not permitted" 怎么办?如果在删除 /usr/local/aegis 等目录时报错,说明文件被设置了底层防篡改属性(i 属性)。可以使用 chattr 解锁后再删除: Bash
# 解除锁定chattr -i /usr/local/aegis# 如果里面的子文件也报错,可以针对具体文件解除# 比如:chattr -i /usr/local/aegis/某个具体文件
完成上述操作后,可以使用 ps -ef | grep aegis ps -ef | grep aliyun 检查,如果没有相关进程,说明已经卸载干净了。
|