centos7 初始化 基礎設定及安全腳本
以下是 CentOS 7 的基本配置和安全脚本:
- 更新系统和软件包:
yum update
- 关闭 SELinux:
注释掉 /etc/selinux/config 文件中的 SELINUX=enforcing 行,然后添加一行 SELINUX=disabled,并重启系统:
reboot
- 安装防火墙并启用:
yum install firewalld
systemctl enable firewalld
systemctl start firewalld
- 配置防火墙规则:
打开必要的端口,例如 HTTP、HTTPS、SSH 等:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
- 安装 fail2ban 以防止暴力攻击:
yum install fail2ban
systemctl enable fail2ban
systemctl start fail2ban
- 安装和配置 rkhunter:
yum install rkhunter
rkhunter --update
rkhunter --propupd
- 安装和配置 logwatch:
yum install logwatch
- 配置 SSH 以增强安全性:
编辑 /etc/ssh/sshd_config 文件并进行以下更改:
PermitRootLogin no
PasswordAuthentication no
然后重启 SSH 服务:
systemctl restart sshd
- 安装和配置 tripwire:
yum install tripwire
以上是 CentOS 7 的基本配置和安全脚本,但仍需进行其他安全措施,例如使用强密码、禁止使用 root 用户登录、禁用不必要的服务等。可以参考其他安全指南进行更多配置。
原文地址: https://www.cveoy.top/t/topic/3tm 著作权归作者所有。请勿转载和采集!