首页
人工智能
网络安全
手机
搜索
登录
搜索
golden81
累计撰写
154
篇文章
累计收到
0
条评论
首页
栏目
首页
人工智能
网络安全
手机
包含标签 【完整性检查】 的文章
2025-4-23
Linux系统安全笔记
一、账户与认证安全 1. 用户账户管理 # 查看所有用户 cat /etc/passwd # 查看密码过期信息 chage -l username # 设置密码策略(/etc/login.defs) PASS_MAX_DAYS 90 # 密码最长有效期 PASS_MIN_DAYS 7 # 密码修改间隔 PASS_MIN_LEN 8 # 最小密码长度 PASS_WARN_AGE 14 # 密码过期提醒 # 使用PAM强化密码复杂度(/etc/pam.d/system-auth) password requisite pam_pwquality.so try_first_pass retry=3 minlen=10 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 2. SSH安全配置(/etc/ssh/sshd_config) Port 2222 # 修改默认端口 PermitRootLogin no # 禁止root直接登录 MaxAuthTries 3 # 最大认证尝试次数 ClientAliveInterval 300 # 客户端活动检查间隔 ClientAliveCountMax 2 # 客户端活动检查次数 AllowUsers user1 user2 # 只允许特定用户登录 PasswordAuthentication no # 禁用密码认证(使用密钥) PubkeyAuthentication yes # 启用公钥认证 3. Sudo安全 # 配置sudoers文件(visudo命令) Defaults logfile=/var/log/sudo.log # 记录sudo操作 Defaults timestamp_timeout=5 # sudo密码缓存时间(分钟) %wheel ALL=(ALL) ALL # 只允许wheel组成员使用sudo 二、文件系统安全 1. 权限管理 # 关键目录权限设置 chmod 750 /home/* # 用户home目录 chmod 700 /etc/ssh # SSH配置目录 chmod 644 /etc/passwd /etc/group # 账户文件 chmod 600 /etc/shadow # 密码文件 # 设置粘滞位(仅目录所有者可删除文件) chmod +t /tmp # 查找SUID/SGID文件 find / -perm -4000 -type f -exec ls -ld {} \; find / -perm -2000 -type f -exec ls -ld {} \; 2. 文件完整性检查 # 使用AIDE(高级入侵检测环境) aide --init mv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz aide --check # 使用tripwire进行文件完整性检查 三、网络安全 1. 防火墙配置(firewalld/iptables) # 基本防火墙规则(firewalld) firewall-cmd --permanent --add-service=ssh firewall-cmd --permanent --remove-service=dhcpv6-client firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="http" accept' firewall-cmd --reload 2. 网络服务安全 # 禁用不必要的服务 systemctl disable rpcbind systemctl disable avahi-daemon # 使用TCP Wrappers(/etc/hosts.allow和/etc/hosts.deny) sshd: 192.168.1.0/24 # hosts.allow ALL: ALL # hosts.deny 四、日志与监控 1. 系统日志配置(rsyslog) # 配置/etc/rsyslog.conf auth,authpriv.* /var/log/auth.log *.info;mail.none;authpriv.none /var/log/messages # 启用日志轮转(logrotate) 2. 入侵检测 # 使用fail2ban防止暴力 yum install fail2ban systemctl enable fail2ban systemctl start fail2ban # 配置/etc/fail2ban/jail.local [sshd] enabled = true port = ssh filter = sshd logpath = /var/log/auth.log maxretry = 3 bantime = 3600 五、内核安全加固 1. sysctl安全配置(/etc/sysctl.conf) # 禁用IP转发 net.ipv4.ip_forward = 0 # 启用SYN Cookie保护 net.ipv4.tcp_syncookies = 1 # 禁用ICMP重定向 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.default.accept_redirects = 0 # 应用配置 sysctl -p 2. 使用SELinux/AppArmor # SELinux基本命令 getenforce # 查看状态 setenforce 1 # 启用 setenforce 0 # 禁用 # 查看SELinux上下文 ls -Z ps -Z # 修改文件上下文 chcon -t httpd_sys_content_t /var/www/html 六、安全工具推荐 扫描:OpenVAS, Nessus 检测:rkhunter, chk网络监控:Wireshark, tcpdump 端口扫描检测:psad Web应用防火墙:ModSecurity 七、应急响应流程 识别事件:分析日志、异常进程、网络连接 隔离系统:断开网络连接 取证分析:保存日志、内存dump、可疑文件 清除威胁:删除恶意文件、修补恢复服务:从干净备份恢复 事后分析:编写事件报告,改进防御措施 八、最佳实践 定期更新系统和软件包 最小化安装原则(只安装必要的服务) 实施最小权限原则 定期备份重要数据并验证 启用审计功能(auditd) 对敏感数据加密(LUKS, GPG) 建立完善的安全策略和操作规范
2025年-4月-23日
18 阅读
0 评论
网络安全