当前位置:首页>Linux>Linux 服务器安全加固与基线配置实战指南

Linux 服务器安全加固与基线配置实战指南

  • 2026-08-18 23:11:37
Linux 服务器安全加固与基线配置实战指南
适用系统: CentOS 7/8 / Rocky Linux / openEuler / Ubuntu 20.04+
等保等级: 二级/三级 通用安全配置基线



1. 安全加固总览

1.1 为什么要做安全加固?

服务器安全不是为了防住所有人,而是:- 让"路过的小白"进不来- 让"脚本小子"多花几小时- 让"专业攻击者"留下足够多的日志最终目标:攻击成本 > 你的服务器价值

1.2 安全加固的维度

┌──────────────────────────────────────────────────┐│                  安全加固金字塔                     ││                    ▲                              ││         ┌─────────┴──────────┐                   ││         │   入侵检测/响应      │   ← Fail2Ban, WAF ││         ├────────────────────┤                    ││         │   文件完整性校验      │   ← AIDE, Tripwire││         ├────────────────────┤                    ││         │   日志审计与监控      │   ← auditd, rsyslog││         ├────────────────────┤                    ││         │   服务最小化          │   ← 只装需要的包   ││         ├────────────────────┤                    ││         │   系统加固            │   ← 内核参数, 防火墙││         ├────────────────────┤                    ││         │   账户与访问控制      │   ← SSH, sudo, PAM ││         ├────────────────────┤                    ││         │   物理安全 / BIOS     │   ← 服务器机房     ││         └────────────────────┘                    │└──────────────────────────────────────────────────┘



2. SSH 安全加固

2.1 SSH 配置文件加固

编辑 /etc/ssh/sshd_config

# SSH 端口(建议修改默认 22 端口)Port 2222# 禁止 root 直接登录(推荐)PermitRootLogin no# 使用密钥认证PubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keys# 禁止密码登录(纯密钥环境)PasswordAuthentication noChallengeResponseAuthentication noUsePAM no# 允许的用户白名单(只允许这些用户 SSH)AllowUsers ops admin deploy# SSH 协议版本Protocol 2# 闲置超时断开ClientAliveInterval 300ClientAliveCountMax 2# 登录尝试次数限制MaxAuthTries 3MaxSessions 10# 禁用不安全的算法Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.comMACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.comKexAlgorithms curve25519-sha256,diffie-hellman-group-exchange-sha256# 禁止空密码PermitEmptyPasswords no# 打印最后登录信息PrintLastLog yes# SSH 日志级别LogLevel VERBOSE# X11 转发(非必要关闭)X11Forwarding no
修改后重启 SSH 服务:
sshd -t                      # 检查语法systemctl restart sshd       # CentOS / openEuler# systemctl restart ssh      # Ubuntu

2.2 密钥管理与分发

# 生成 Ed25519 密钥(推荐,比 RSA 更安全更快)ssh-keygen -t ed25519 -a 100 -f ~/.ssh/id_ed25519 -C "ops@company.com"# 备用 RSA 密钥(兼容老旧系统)ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -C "ops@company.com"# 分发公钥到目标服务器ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 2222 ops@server-ip# 批量分发公钥(使用 sshpass 或 ansible)# ansible 方式:ansible all -m authorized_key -a "user=ops key='{{ lookup('file', '/home/ops/.ssh/id_ed25519.pub') }}'"

2.3 证书登录(大规模环境推荐)

对于 20 台以上服务器,建议使用 SSH CA(证书颁发机构):

# Step 1: 创建 SSH CA 密钥(在管理机上操作)ssh-keygen -t ed25519 -f ~/.ssh/ca_user_key -C "SSH CA Key"# 生成两个文件:#   ca_user_key        → CA 私钥(放在保险柜里!)#   ca_user_key.pub    → CA 公钥(分发到所有服务器)# Step 2: 在每台服务器上配置信任 CAecho "TrustedUserCAKeys /etc/ssh/ca_user_key.pub" >> /etc/ssh/sshd_configecho "principals=\"ops,admin\"" >> /etc/ssh/sshd_config# 复制 CA 公钥到服务器scp ~/.ssh/ca_user_key.pub ops@server:/tmp/ssh ops@server "sudo cp /tmp/ca_user_key.pub /etc/ssh/ && sudo chmod 644 /etc/ssh/ca_user_key.pub"ssh ops@server "sudo systemctl restart sshd"# Step 3: 使用 CA 为运维用户签发证书ssh-keygen -s ~/.ssh/ca_user_key \  -I "ops-2026" \  -n "ops,admin" \  -V "+52w" \          # 有效期 1 年  ~/.ssh/id_ed25519.pub# 生成的文件:~/.ssh/id_ed25519-cert.pub# Step 4: 用证书登录ssh -i ~/.ssh/id_ed25519 ops@server-ip# 不需要提前分发公钥!# 服务器验证的是 CA 签名,不是具体密钥

2.4 安全加固验证

# 检查 SSH 配置安全性# 使用 ssh-audit 工具pip3 install ssh-auditssh-audit localhost# 或手动检查sshd -T | grep -E "port|permitrootlogin|passwordauthentication|pubkey"



3. 账户管理与权限控制

3.1 用户与组管理

# 创建运维用户useradd -m -s /bin/bash opspasswd ops# 按角色分组groupadd admin          # 管理员组groupadd devops         # 运维开发组groupadd readonly       # 只读查看组# 用户加入对应组usermod -aG admin opsusermod -aG wheel ops   # CentOS 中 wheel 组有 sudo 权限

3.2 sudo 权限精细化

创建独立的 sudo 配置:

/etc/sudoers.d/ops — 管理员组%admin ALL=(ALL) NOPASSWD: ALL# /etc/sudoers.d/devops — 运维开发组%devops ALL=(ALL) NOPASSWD: /usr/bin/systemctl, /usr/bin/journalctl, /usr/bin/docker# /etc/sudoers.d/readonly — 只读组%readonly ALL=(ALL) NOPASSWD: /usr/bin/cat, /usr/bin/less, /usr/bin/tail, /usr/bin/grep# 检查 sudo 配置语法visudo -c

3.3 密码策略

# 安装 pwqualityyum install -y libpwquality   # CentOS / openEuler# apt install -y libpam-pwquality  # Ubuntu# 配置 /etc/security/pwquality.confcat > /etc/security/pwquality.conf << 'EOF'# 最小长度minlen = 14# 最少数字dcredit = -1# 最少大写字母ucredit = -1# 最少小写字母lcredit = -1# 最少特殊字符ocredit = -1# 最大重复字符maxrepeat = 3# 最少字符类数(数字、大写、小写、特殊符号)minclass = 4# 禁止使用用户名usercheck = 1# 与旧密码差异字符数difok = 5# 尝试次数enforce_for_rootEOF# 密码过期策略 — /etc/login.defsPASS_MAX_DAYS   90PASS_MIN_DAYS   7PASS_WARN_AGE   14

3.4 闲置账户清理

#!/bin/bash# 检查 90 天未登录的账户echo "=== 90 天未登录账户 ==="lastlog -b 90 | grep -v "Never logged" | grep -v "Username"# 检查 UID 0 的非 root 账户(后门风险)echo "=== UID 0 账户 ==="awk -F: '($3 == 0) {print $1}' /etc/passwd# 检查空密码账户echo "=== 空密码账户 ==="awk -F: '($2 == "") {print $1}' /etc/shadow



4. 防火墙与网络加固

4.1 firewalld(CentOS / openEuler)

# 默认拒绝入站firewall-cmd --set-default-zone=drop# 只放行必要的服务firewall-cmd --permanent --add-port=2222/tcp       # SSH(改过的端口)firewall-cmd --permanent --add-service=http         # Webfirewall-cmd --permanent --add-service=https        # Web SSLfirewall-cmd --permanent --add-port=9090/tcp        # 监控(按需)# 限制来源 IPfirewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="22" protocol="tcp" accept'firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.0.0/16" port port="22" protocol="tcp" accept'# 应用规则firewall-cmd --reload# 查看规则firewall-cmd --list-all

4.2 iptables 模式(Ubuntu / 自定义)

#!/bin/bash# iptables 加固脚本# 清空规则iptables -Fiptables -Xiptables -Z# 默认策略:拒绝所有iptables -P INPUT DROPiptables -P FORWARD DROPiptables -P OUTPUT ACCEPT# 回环接口放行iptables -A INPUT -i lo -j ACCEPT# 已建立的连接放行iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT# SSH(指定白名单)iptables -A INPUT -p tcp --dport 2222 -s 10.0.0.0/8 -j ACCEPTiptables -A INPUT -p tcp --dport 2222 -s 192.168.0.0/16 -j ACCEPT# Web 服务iptables -A INPUT -p tcp --dport 80 -j ACCEPTiptables -A INPUT -p tcp --dport 443 -j ACCEPT# ICMP(限制 ping 频率,防 flood)iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/second -j ACCEPT# 防 SYN Floodiptables -A INPUT -p tcp --syn -m limit --limit 100/second --limit-burst 200 -j ACCEPT# 日志记录(放到最后,只记录被拒绝的)iptables -A INPUT -j LOG --log-prefix "FW-DROP: " --log-level 4# 保存规则iptables-save > /etc/iptables/rules.v4

4.3 TCP Wrappers(传统保护)

# /etc/hosts.allow — 白名单sshd10.0.0.,192.168.0. : allowsshdALL : deny

4.4 网络层防护

# 禁用 IP 转发(除非是路由器)sysctl -w net.ipv4.ip_forward=0# 禁用 ICMP 重定向sysctl -w net.ipv4.conf.all.accept_redirects=0sysctl -w net.ipv4.conf.all.send_redirects=0# 启用反向路径过滤(防 IP 欺骗)sysctl -w net.ipv4.conf.all.rp_filter=1



5. SELinux / AppArmor

5.1 SELinux(CentOS / openEuler)

# 不建议直接关闭 SELinux!# 正确的姿势:Permissive 模式 + 审计日志 => 调整策略 => 开启 Enforcing# 检查状态getenforcesestatus# 临时设为 Permissive(排查问题时)setenforce 0# 永久修改(编辑 /etc/selinux/config)sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config# 查看 SELinux 审计日志(重点!)ausearch -m avc -ts recentgrep "avc:" /var/log/audit/audit.log# 生成 SELinux 策略模块(基于审计日志)audit2allow -a -M my_custom_policysemodule -i my_custom_policy.pp# 常用 SELinux 操作semanage port -l | grep http          # 查看端口标签semanage fcontext -l | grep /var/www  # 查看文件上下文restorecon -Rv /var/www/html          # 恢复文件上下文chcon -t httpd_sys_content_t /var/www/html -R  # 修改上下文

5.2 AppArmor(Ubuntu)

# 检查状态aa-status# 设置模式aa-complain /usr/sbin/sshd    # 审计模式aa-enforce /usr/sbin/sshd     # 强制模式# 查看和编辑策略vim /etc/apparmor.d/usr.sbin.sshd# 重新加载systemctl reload apparmor# 查看 AppArmor 日志grep "apparmor" /var/log/syslog



6. 内核参数安全优化

编辑 /etc/sysctl.d/99-security.conf

# ============================================# 网络安全参数# ============================================# 禁用 IP 转发net.ipv4.ip_forward = 0net.ipv6.conf.all.forwarding = 0# 禁用 ICMP 重定向net.ipv4.conf.all.accept_redirects = 0net.ipv4.conf.default.accept_redirects = 0net.ipv6.conf.all.accept_redirects = 0net.ipv4.conf.all.send_redirects = 0net.ipv4.conf.default.send_redirects = 0# 禁用源路由net.ipv4.conf.all.accept_source_route = 0net.ipv4.conf.default.accept_source_route = 0net.ipv6.conf.all.accept_source_route = 0# 启用反向路径过滤net.ipv4.conf.all.rp_filter = 1net.ipv4.conf.default.rp_filter = 1# 忽略伪装的 ICMP 请求net.ipv4.icmp_echo_ignore_broadcasts = 1net.ipv4.icmp_ignore_bogus_error_responses = 1# ============================================# TCP 安全加固# ============================================# 启用 SYN Cookie(防 SYN Flood 攻击)net.ipv4.tcp_syncookies = 1# SYN 队列长度net.ipv4.tcp_max_syn_backlog = 2048# SYN-ACK 重试次数net.ipv4.tcp_synack_retries = 2# TIME_WAIT 重用net.ipv4.tcp_tw_reuse = 1# 缩减 FIN 超时net.ipv4.tcp_fin_timeout = 15# 开启 TCP Keepalivenet.ipv4.tcp_keepalive_time = 300net.ipv4.tcp_keepalive_probes = 5net.ipv4.tcp_keepalive_intvl = 15# ============================================# 内存与系统保护# ============================================# 地址空间布局随机化(ASLR)kernel.randomize_va_space = 2# 限制 ptracekernel.yama.ptrace_scope = 1# 核心转储限制fs.suid_dumpable = 0kernel.core_uses_pid = 1# 魔术系统请求键kernel.sysrq = 0# 消息队列限制kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296# 增加文件描述符限制fs.file-max = 6553500fs.nr_open = 6553500
应用参数:
sysctl -p /etc/sysctl.d/99-security.conf



7. 日志审计

7.1 auditd 配置

yum install -y audit audispd-plugins   # CentOSsystemctl enable --now auditd# 审计规则 — /etc/audit/rules.d/audit.rulescat > /etc/audit/rules.d/audit.rules << 'EOF'# 清除默认规则-D-b 8192# 禁止修改审计规则-w /etc/audit/rules.d/ -p wa -k audit_rules-w /etc/audit/audit.rules -p wa -k audit_rules# 监控关键系统文件-w /etc/passwd -p wa -k identity-w /etc/shadow -p wa -k identity-w /etc/group -p wa -k identity-w /etc/sudoers -p wa -k sudoers-w /etc/sudoers.d/ -p wa -k sudoers-w /etc/ssh/sshd_config -p wa -k sshd_config# 监控系统关键程序执行-w /usr/bin/passwd -p x -k passwd-w /usr/bin/su -p x -k su-w /usr/bin/sudo -p x -k sudo-w /usr/sbin/sshd -p x -k sshd# 监控网络配置更改-w /etc/hosts -p wa -k hosts-w /etc/resolv.conf -p wa -k resolv-w /etc/sysconfig/network -p wa -k network# 监控系统启动脚本-w /etc/rc.local -p wa -k startup-w /etc/init.d/ -p wa -k init# 监控计划任务-w /etc/crontab -p wa -k cron-w /etc/cron.d/ -p wa -k cron-w /var/spool/cron/ -p wa -k cron# 系统调用审计(重要)-a always,exit -F arch=b64 -S execve -k exec-a always,exit -F arch=b32 -S execve -k exec# 监控时间修改-a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time-change-a always,exit -F arch=b32 -S adjtimex -S settimeofday -k time-change# 监控模块加载-w /sbin/insmod -p x -k modules-w /sbin/rmmod -p x -k modules-w /sbin/modprobe -p x -k modules# 文件访问权限修改-a always,exit -F arch=b64 -S chmod -S fchmod -S chown -S fchown -S lchown -k perm_mod-a always,exit -F arch=b32 -S chmod -S fchmod -S chown -S fchown -S lchown -k perm_mod# 监控 mount-a always,exit -F arch=b64 -S mount -k mount# 保证规则被加载-e 2EOF# 重新加载规则auditctl -R /etc/audit/rules.d/audit.rules# 查看审计规则auditctl -l

7.2 审计日志查询

# 基本搜索ausearch -k identity -ts today          # 今天谁改了密码文件ausearch -k sudo -ts 10:00              # 10点后的 sudo 事件ausearch -u root -ts this-week          # root 用户本周操作# 生成报告aureport --summary                      # 审计概要aureport -l --failed                    # 失败事件aureport -u                             # 用户报告# 实时监控tail -f /var/log/audit/audit.log | ausearch -k sshd

7.3 日志远程集中管理

# rsyslog 客户端配置(所有服务器)cat > /etc/rsyslog.d/remote-logging.conf << 'EOF'# 发送到日志中心*.* @@192.168.100.50:514   # TCP 方式# *.* @192.168.100.50:514   # UDP 方式(不太可靠)# 磁盘缓存(防网络中断丢日志)$ActionQueueFileName queue$ActionQueueMaxDiskSpace 1g$ActionQueueSaveOnShutdown on$ActionQueueType LinkedList$ActionResumeRetryCount -1EOFsystemctl restart rsyslog



8. 文件完整性校验

8.1 AIDE(Advanced Intrusion Detection Environment)

# 安装yum install -y aide# 初始化数据库(第一次运行)aide --initmv /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz# 配置监控路径 — /etc/aide.confcat > /etc/aide.conf << 'EOF'# 定义规则All = p+i+n+u+g+s+m+c+md5+sha256Log = p+i+n+u+g+s+m+c+md5+sha256+sha512# p=权限 i=inode n=链接数 u=用户 g=组 s=大小 m=mtime c=ctime# 监控的目录/etc All/usr/bin All/usr/sbin All/usr/local/bin All/usr/local/sbin All/boot All/root All/var/log Log# 排除项!/var/log/wtmp!/var/log/btmp!/var/log/lastlog!/var/log/sa!/proc!/sys!/dev!/run!/mnt!/media!/tmpEOF# 每日检查脚本cat > /etc/cron.daily/aide-check << 'SCRIPT'#!/bin/bashAIDE_DB="/var/lib/aide/aide.db.gz"AIDE_REPORT="/var/log/aide-report-$(date +%Y%m%d).txt"# 运行完整性检查aide --check > ${AIDE_REPORT} 2>&1# 如果有变更,邮件通知if grep -q "changed" ${AIDE_REPORT}then    mail -s "AIDE: 文件完整性告警 - $(hostname)" ops@company.com < ${AIDE_REPORT}fi# 保留最近 30 天报告find /var/log/aide-report-*.txt -mtime +30 -deleteSCRIPTchmod +x /etc/cron.daily/aide-check

8.2 RPM 包校验(CentOS / openEuler 原生)

# 验证所有已安装软件包的完整性rpm -Va > /tmp/rpm-v-check.txt# 只看配置文件变更rpm -Va | grep "^..5" > /tmp/rpm-config-changed.txt# 验证特定包rpm -V openssh-server# 意义:输出字段说明# S=文件大小 M=权限 5=MD5 D=设备 L=链接 U=用户 G=组 T=时间



9. 软件包与服务管理

9.1 服务最小化原则

# 列出所有运行的服务systemctl list-units --type=service --state=running# 禁用不必要的服务(仅示例,按实际需求)systemctl disable --now postfix           # 邮件发送(不需要时)systemctl disable --now avahi-daemon      # mDNS 发现服务systemctl disable --now cups              # 打印服务(服务器不需要)systemctl disable --now bluetooth         # 蓝牙(服务器不需要)systemctl disable --now rpcbind           # NFS(不需要时)systemctl disable --now telnet.socket     # Telnet 必须禁用systemctl disable --now rlogin.socket     # rlogin 必须禁用systemctl disable --now rexec.socket      # rexec 必须禁用# 查看监听端口,确认没有意外服务ss -tulpn

9.2 软件源与 GPG 验证

# 确保所有仓库使用 GPG 验证grep -r "gpgcheck" /etc/yum.repos.d/# 所有 .repo 文件应包含 gpgcheck=1# 导入 GPG 密钥rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*

9.3 自动安全更新

# CentOS / openEuleryum install -y dnf-automatic# 或 yum-cron# 配置 /etc/dnf/automatic.confcat > /etc/dnf/automatic.conf << 'EOF'[commands]upgrade_type = securityrandom_sleep = 360download_updates = yesapply_updates = yes[emitters]emit_via = motd[base]debuglevel = 1EOF# 启用定时任务systemctl enable --now dnf-automatic.timer# Ubuntuapt install -y unattended-upgradesdpkg-reconfigure --priority=low unattended-upgrades



10. 入侵检测与 Fail2Ban

10.1 Fail2Ban 安装与配置

yum install -y fail2ban   # CentOS# apt install -y fail2ban  # Ubuntu# 主配置 — /etc/fail2ban/jail.localcat > /etc/fail2ban/jail.local << 'EOF'[DEFAULT]# 白名单(运维 IP 不封)ignoreip = 127.0.0.1/8 10.0.0.0/8 192.168.0.0/16# 封禁时间:1 小时bantime = 3600# 发现时间窗口:10 分钟findtime = 600# 阈值:10 分钟内失败 5 次封禁maxretry = 5# 通知方式destemail = ops@company.comsender = fail2ban@$(hostname)action = %(action_mw)s# sshd 防护[sshd]enabled = trueport = 2222logpath = %(sshd_log)smaxretry = 3bantime = 86400   # SSH 爆破直接封 24 小时# SSH 字典攻击(更严格)[sshd-dict]enabled = trueport = 2222filter = sshdlogpath = %(sshd_log)smaxretry = 10findtime = 60     # 1 分钟 10 次失败,一定是字典攻击bantime = 604800  # 封 7 天!EOF# 启动systemctl enable --now fail2ban# 查看状态fail2ban-client statusfail2ban-client status sshd# 查看被封的 IPiptables -L -n | grep f2b# 手动解封 IPfail2ban-client set sshd unbanip 192.168.1.100

10.2 自定义 Fail2Ban 过滤器示例

对于 Web 应用,可以创建自定义过滤器:

# /etc/fail2ban/filter.d/nginx-bot.confcat > /etc/fail2ban/filter.d/nginx-bot.conf << 'EOF'[Definition]failregex = ^<HOST> -.*"(GET|POST).*/(wp-admin|wp-login|admin|manager|phpMyAdmin).*" (404|403|500)ignoreregex =EOF# 添加 Nginx 防护规则到 jail.localecho "[nginx-bot]enabled = trueport = http,httpsfilter = nginx-botlogpath = /var/log/nginx/access.logmaxretry = 10findtime = 300bantime = 86400" >> /etc/fail2ban/jail.localsystemctl restart fail2ban



11. 等保二级/三级合规 Checklist

11.1 物理安全(略,运保部门负责)

11.2 网络安全

检查项等保三级要求检查命令
边界防火墙部署访问控制iptables -L -n
最小化端口仅开放业务端口ss -tulpn
登录失败锁定配置锁定策略cat /etc/pam.d/password-auth
空闲超时断开SSH 超时设置grep ClientAlive /etc/ssh/sshd_config

11.3 主机安全

检查项等保三级要求检查命令
身份鉴别双因素或复杂密码grep minlen /etc/security/pwquality.conf
访问控制最小权限原则cat /etc/sudoers.d/*
安全审计auditd 开启systemctl status auditd && auditctl -l
入侵防范安装入侵检测fail2ban-client status
恶意代码防范安装杀毒软件clamscan --version
剩余信息保护禁用历史命令记录echo "HISTSIZE=1000" >> /etc/profile

11.4 应用安全

检查项等保三级要求备注
Web 安全HTTPS、WAFNginx + ModSecurity
数据加密传输加密TLS 1.2+
备份恢复定期备份异地备份

11.5 等保自查脚本

#!/bin/bash# security-audit.sh — 等保三级安全检查脚本echo "===== 等保三级安全检查 ====="echo "时间: $(date)"echo "主机: $(hostname)"echo ""FAIL=0PASS=0WARN=0check() {    local desc=$1    local cmd=$2    echo -n "[检查] $desc ... "    if eval "$cmd" >/dev/null 2>&1; then        # 判断成功条件        if $3then            echo "✅"            PASS=*** + 1))        else            echo "⚠️"            WARN=$((WARN + 1))        fi    else        echo "❌"        FAIL=$((FAIL + 1))    fi}# 身份鉴别check "密码最小长度 >= 8" 'grep -q "minlen.*8" /etc/security/pwquality.conf' truecheck "密码过期时间 <= 90天" 'grep -q "PASS_MAX_DAYS.*90" /etc/login.defs' truecheck "登录失败锁定" 'grep -q "deny.*3" /etc/pam.d/password-auth' truecheck "SSH 协议版本 2" 'grep -q "Protocol 2" /etc/ssh/sshd_config' true# 访问控制check "禁止 root 登录" 'grep -q "PermitRootLogin no" /etc/ssh/sshd_config' falsecheck "sudo 权限细分" 'test -f /etc/sudoers.d/ops' true# 安全审计check "auditd 运行中" 'systemctl is-active auditd | grep -q active' truecheck "SSH 审核规则" 'auditctl -l | grep -q sshd_config' truecheck "rsyslog 运行" 'systemctl is-active rsyslog | grep -q active' true# 入侵防范check "Fail2Ban 运行" 'systemctl is-active fail2ban | grep -q active' truecheck "SELinux 开启" 'getenforce | grep -q Enforcing' falsecheck "防火墙运行" 'systemctl is-active firewalld | grep -q active' falseecho ""echo "===== 汇总 ====="echo "通过: ${PASS} | 警告: ${WARN} | 失败: ${FAIL}"echo "通过率: $((PASS * 100 / (PASS + WARN + FAIL)))%"



12. 一键加固脚本

将上述所有配置打包成自动化脚本:

#!/bin/bash# harden.sh — Linux 服务器一键安全加固脚本# 用法: chmod +x harden.sh && sudo bash harden.sh# 注意:请在测试环境验证后再上生产!set -eLOGFILE="/var/log/security-hardening-$(date +%Y%m%d-%H%M%S).log"exec > >(tee -a "$LOGFILE") 2>&1echo "===== Linux 安全加固脚本开始 ====="echo "时间: $(date)"echo "主机: $(hostname)"# 检测操作系统if [ -f /etc/redhat-release ]; then    OS="centos"elif [ -f /etc/openEuler-release ]; then    OS="openeuler"elif [ -f /etc/lsb-release ]; then    OS="ubuntu"else    echo "不支持的操作系统!"    exit 1fiecho "操作系统: $OS"# 1. SSH 加固echo ""echo "[1/10] SSH 安全加固..."cp /etc/ssh/sshd_config /etc/ssh/sshd_config.baksed -i 's/^#Port 22/Port 2222/' /etc/ssh/sshd_configsed -i 's/^#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_configsed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_configsed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config# 2. 防火墙echo "[2/10] 防火墙配置..."if [ "$OS" = "ubuntu" ]; then    ufw default deny    ufw allow 2222/tcp    ufw allow 80/tcp    ufw allow 443/tcp    ufw --force enableelse    systemctl enable --now firewalld    firewall-cmd --set-default-zone=drop    firewall-cmd --permanent --add-port=2222/tcp    firewall-cmd --permanent --add-service=http    firewall-cmd --permanent --add-service=https    firewall-cmd --reloadfi# 3. 密码策略echo "[3/10] 密码策略配置..."cat > /etc/security/pwquality.conf << 'EOF'minlen = 14dcredit = -1ucredit = -1lcredit = -1ocredit = -1minclass = 4EOF# 4. 内核参数echo "[4/10] 内核参数优化..."cat > /etc/sysctl.d/99-security.conf << 'EOF'net.ipv4.ip_forward = 0net.ipv4.conf.all.accept_redirects = 0net.ipv4.conf.all.send_redirects = 0net.ipv4.tcp_syncookies = 1net.ipv4.conf.all.rp_filter = 1kernel.randomize_va_space = 2kernel.yama.ptrace_scope = 1fs.suid_dumpable = 0EOFsysctl -p /etc/sysctl.d/99-security.conf# 5. 审计echo "[5/10] 审计规则配置..."systemctl enable --now auditdauditctl -Dauditctl -w /etc/passwd -p wa -k identityauditctl -w /etc/shadow -p wa -k identityauditctl -w /etc/sudoers -p wa -k sudoauditctl -w /etc/ssh/sshd_config -p wa -k sshdauditctl -e 1# 6. 安装 Fail2Banecho "[6/10] 安装 Fail2Ban..."if [ "$OS" = "ubuntu" ]; then    apt update && apt install -y fail2banelse    yum install -y fail2banfi# 7. 服务最小化echo "[7/10] 禁用不必要服务..."for svc in postfix avahi-daemon cups bluetooth telnet.socket rlogin.socket rexec.socket; do    systemctl disable --now $svc 2>/dev/null || truedone# 8. 自动安全更新echo "[8/10] 配置自动安全更新..."if [ "$OS" = "ubuntu" ]; then    apt install -y unattended-upgrades    dpkg-reconfigure --priority=low unattended-upgradeselse    yum install -y dnf-automatic    sed -i 's/^apply_updates.*/apply_updates = yes/' /etc/dnf/automatic.conf    systemctl enable --now dnf-automatic.timerfi# 9. 安装 AIDEecho "[9/10] 安装 AIDE..."yum install -y aideaide --initcp /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz# 10. 安装 ClamAV(可选)echo "[10/10] 安装 ClamAV..."yum install -y clamav clamav-updatefreshclamecho ""echo "===== 安全加固完成!====="echo "加固日志: ${LOGFILE}"echo ""echo "⚠️  请手动检查和操作:"echo "  1. 在另一终端保持 SSH 连接,测试新端口 2222"echo "  2. 确认能正常登录后再关闭当前终端"echo "  3. 检查应用是否正常,防火墙配置可能需要调整"echo "  4. 建议重启服务器确认所有配置生效"

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 15:31:33 HTTP/2.0 GET : https://f.mffb.com.cn/a/508351.html
  2. 运行时间 : 0.335093s [ 吞吐率:2.98req/s ] 内存消耗:4,748.61kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=671695e0e92278181a61ab37b1c6cc80
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.001254s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.002176s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.007647s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.003992s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001547s ]
  6. SELECT * FROM `set` [ RunTime:0.000539s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001486s ]
  8. SELECT * FROM `article` WHERE `id` = 508351 LIMIT 1 [ RunTime:0.012813s ]
  9. UPDATE `article` SET `lasttime` = 1787297494 WHERE `id` = 508351 [ RunTime:0.043682s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.011199s ]
  11. SELECT * FROM `article` WHERE `id` < 508351 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.021444s ]
  12. SELECT * FROM `article` WHERE `id` > 508351 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.005445s ]
  13. SELECT * FROM `article` WHERE `id` < 508351 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002124s ]
  14. SELECT * FROM `article` WHERE `id` < 508351 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.003051s ]
  15. SELECT * FROM `article` WHERE `id` < 508351 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.015841s ]
0.340848s