CentOS 7 服务器安全加固指南
一、用户与权限管理
# 禁用root远程登录 vim /etc/ssh/sshd_config PermitRootLogin no PasswordAuthentication no # 创建普通用户并加入sudo组 useradd -m -s /bin/bash admin usermod -aG wheel admin
二、防火墙配置
# 启动firewalld systemctl start firewalld systemctl enable firewalld # 开放常用端口 firewall-cmd --permanent --add-port=22/tcp firewall-cmd --permanent --add-port=80/tcp firewall-cmd --reload
三、SSH安全配置
# 修改SSH默认端口 vim /etc/ssh/sshd_config Port 2222 # 重启SSH服务 systemctl restart sshd
四、安装fail2ban防暴力破解
yum install fail2ban -y systemctl enable fail2ban systemctl start fail2ban