等保2.0 三级 — 安全加固全攻略
适用场景:等保 2.0 三级合规建设 | 参考标准:GB/T 22239-2019 设备范围:交换机 + Windows Server + Linux Server
目录
一、交换机安全加固
通用约定:SSH 端口改 10022,ACL 编号 2001/3001,日志服务器 x.x.x.x
支持型号
厂商
型号
版本
华三 (H3C)
S3600-28TP-EI
V5.20
华三 (H3C)
S5570S-54S-EI
V7.1.070
华为 (Huawei)
S5720-32P-EI-AC
V200R007 系列
华为 (Huawei)
S5735S-S48T4X-A
V200R022 系列(配置同 5720)
迈普 (MAIPU)
MES2452
V6.6.4
博达 (BDCOM)
S3956
V2.2.0
思科 (Cisco)
—
IOS
1. 远程管理安全(SSH) 1.1 启用 SSH + 修改默认端口 华三 (H3C) V5.20
1 2 3 4 5 6 7 system-view crypto key generate rsa ssh server enable ssh server port 10022 ssh server acl 2001 return save force
华三 (H3C) V7
1 2 3 4 5 6 7 8 system-view crypto key generate rsa ssh server enable ssh server port 10022 ssh server acl 2001 ssh server authentication-retries 5 return save force
华为 (Huawei) V200R
1 2 3 4 5 6 7 8 system-view rsa local-key-pair create ssh server enable ssh server port 10022 ssh server acl 2001 ssh server authentication-retries 5 return save
迈普 (MAIPU)
1 2 3 4 5 6 7 8 9 configure crypto key generate rsa ip ssh server ip ssh port 10022 ip sshd access-class 2001 ip sshd auth-retries 5 ip sshd timeout 300 exit write
博达 (BDCOM)
1 2 3 4 5 6 7 8 9 configure crypto key generate rsa ip ssh server ip ssh port 10022 ip sshd access-class 2001 ip sshd auth-retries 5 ip sshd timeout 300 exit write
思科 (Cisco)
1 2 3 4 5 configure terminal crypto key generate rsa modulus 2048 ip ssh version 2 end write memory
⚠️ 思科 IOS 不支持直接修改 SSH 端口(无 ip ssh port 命令),如需修改端口号,需借助上游设备做端口映射。
1.2 ACL 限制管理 IP 华三 (H3C) V5.20
1 2 3 4 5 6 7 8 9 10 system-view acl number 2001 rule 5 permit source 172.16.11.0 0.0.0.255 rule 10 deny any quit user-interface vty 0 4 acl 2001 inbound quit return save force
华为 (Huawei) V200R
1 2 3 4 5 6 7 8 9 10 system-view acl 2001 rule 5 permit source 172.16.11.0 0.0.0.255 rule 10 deny any quit user-interface vty 0 4 acl 2001 inbound quit return save
迈普 (MAIPU)
1 2 3 4 5 6 7 8 9 configure ip access-list standard 2001 permit 172.16.11.0 0.0.0.255 deny any exit line vty 0 4 access-class 2001 in exit write
博达 (BDCOM) — 同上
思科 (Cisco)
1 2 3 4 5 6 7 8 9 10 configure terminal ip access-list standard MANAGEMENT permit 172.16.11.0 0.0.0.255 deny any exit line vty 0 4 access-class MANAGEMENT in exit end write memory
1.3 本地认证与 Console 认证 华三 (H3C)
1 2 3 4 5 6 7 8 9 10 system-view local-user admin123 class manage password hash xxxx service-type ssh telnet authorization attribute level 3 user-interface con 0 authentication-mode password set authentication password cipher P@ssw0rd! quit save force
华为 (Huawei)
1 2 3 4 5 6 7 8 9 10 system-view aaa local-user admin123 password irreversible-cipher xxxx local-user admin123 service-type http ssh telnet local-user admin123 privilege level 15 quit user-interface con 0 authentication-mode aaa quit save
1.4 禁用不安全服务 华为 / 华三
1 2 3 undo telnet server undo http server undo ftp server enable
2. 账号与口令管理 2.1 三权分立账号
账号
角色
权限等级
admin_sys
系统管理员
level 3/15
auditor
安全审计员
level 2/3(只读)
inspector
日常巡检员
level 1(最低)
华为 (Huawei)
1 2 3 4 5 6 7 8 9 10 11 12 13 system-view aaa local-user admin_sys password irreversible-cipher Sys@Admin2026 local-user admin_sys privilege level 15 local-user admin_sys service-type ssh telnet http local-user auditor password irreversible-cipher Aud@itor2026 local-user auditor privilege level 3 local-user auditor service-type ssh local-user inspector password irreversible-cipher Insp@ctor2026 local-user inspector privilege level 1 local-user inspector service-type ssh quit save
华三 (H3C)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 system-view local-user admin_sys class manage password hash xxxx service-type ssh telnet authorization attribute level 3 local-user auditor class manage password hash xxxx service-type ssh authorization attribute level 2 local-user inspector class manage password hash xxxx service-type ssh authorization attribute level 1 save force
2.2 密码策略 华为 (Huawei)
1 2 3 4 5 6 7 8 9 system-view aaa local-aaa-user password policy administrator password expire 90 password alert before-expire 14 password alert original password history record number 5 quit save
华三 (H3C)
1 2 3 4 5 system-view password-policy length 12 password-policy complexity password expiration 90 save force
3. 登录安全 3.1 登录超时(≤5 分钟) 华为 / 华三
1 2 3 4 5 6 system-view user-interface vty 0 4 idle-timeout 5 0 screen-length 0 quit save force
迈普 / 博达
1 2 3 4 5 configure line vty 0 4 exec-timeout 5 0 exit write
3.2 登录失败锁定(5 次,锁定 20 分钟) 华为
1 2 3 4 5 system-view aaa local-user admin123 login-fail attempts 5 within 20 quit quit save
华三
1 2 3 4 system-view ssh server authentication-retries 5 ssh server login-fail lock 20 save force
4. SNMP 安全
启用 SNMPv3,不使用 v1/v2c
华为
1 2 3 4 5 system-view snmp-agent group v3 admin privacy notify-view all snmp-agent usm-user v3 admin admin_auth AES 128 authprivkey123 privacy DES56 snmp-agent acl 2002 save
华三
1 2 3 4 5 system-view snmp-agent group v3 admin privacy snmp-agent usm-user v3 admin admin_auth AES 128 authprivkey123 privacy DES56 snmp-agent acl 2002 save force
5. 日志审计 华为
1 2 3 4 5 6 system-view info-center loghost x.x.x.x channel 4 info-center timestamp debugging date-time info-center loghost source VLANIF 1 quit save
华三
1 2 3 4 system-view info-center loghost x.x.x.x info-center timestamp debugging date-time save force
迈普
1 2 3 4 5 configure logging host x.x.x.x logging facility local0 logging level warnings write
6. 交换机加固小结(检查清单)
一、交换机安全加固(续)
7. 迈普/博达 补充加固项
以下为迈普 (MyPower) 和博达 (BDCOM) 额外加固命令
7.1 账号安全(三权分立) 1 2 configure username admin_sys privilege 15 password Sys@Admin2026
1 2 configure username auditor privilege 10 password Aud@itor2026
1 2 configure username inspector privilege 5 password Insp@ctor2026
7.2 密码策略 1 2 configure security passwords min-length 12
1 2 configure security passwords expiration 90
7.3 禁用不安全服务 1 2 configure no ip telnet server
1 2 configure no ip http server
7.4 SNMPv3 安全 1 2 configure snmp-server group ADMIN v3 priv
1 2 configure snmp-server user monitor ADMIN v3 auth sha AuthKey2026 priv aes 128 PrivKey2026
7.5 端口安全 1 2 3 configure interface <未使用端口> shutdown
1 2 3 configure interface <在用端口> switchport mode access
1 2 configure switchport port-security
1 2 configure switchport port-security maximum 1
7.6 登录 Banner
8. 中兴 ZXR10 C89E 系列
中兴 ZXR10 系列,CLI 风格介于 Cisco 和华为之间
8.1 SSH 远程管理 1 2 system-view crypto key generate rsa
1 2 system-view ssh-server enable
1 2 system-view ssh-server port 10022
1 2 3 4 system-view ip access-list standard SSH_ACL permit 172.16.11.0 0.0.0.255 deny any
1 2 system-view ssh-server access-class SSH_ACL
8.2 登录安全 1 2 3 system-view line vty 0 4 exec-timeout 5 0
1 2 3 4 system-view banner motd # Unauthorized access is prohibited! #
8.3 三权分立账号 1 2 system-view username admin_sys privilege 15 password Sys@Admin2026
1 2 system-view username auditor privilege 10 password Aud@itor2026
1 2 system-view username inspector privilege 5 password Insp@ctor2026
8.4 ACL 访问控制 1 2 3 4 system-view ip access-list standard MANAGEMENT_ACL permit 172.16.11.0 0.0.0.255 deny any
8.5 禁用不安全服务 1 2 system-view no telnet server enable
8.6 SNMPv3 安全 1 2 system-view snmp-server group SNMPv3_GROUP v3 priv
1 2 system-view snmp-server usm-user SNMPv3_USER SNMPv3_GROUP v3
8.7 端口安全 1 2 3 system-view interface GigabitEthernet 1/0/1 shutdown
1 2 3 system-view interface GigabitEthernet 1/0/2 port-security enable
8.8 日志审计 1 2 system-view logging host x.x.x.x
1 2 system-view service timestamps log datetime
8.9 中兴 ZXR10 检查清单
二、Windows 服务器安全加固
系统:Windows Server | 以下操作均为 GUI 可视化操作
1. 账号与认证 1.1 屏保设置(10 分钟自动锁屏) 操作路径:Win + R → gpedit.msc → 计算机配置 → 管理模板 → 控制面板 → 个性化
设置项
操作
屏幕保护程序超时
启用 → 设置 600 秒
密码保护屏幕保护程序
启用
1.2 密码策略 操作路径:Win + R → secpol.msc → 账户策略 → 密码策略
策略
建议值
操作
密码最长使用期限
90 天
双击输入 90
密码最短使用期限
7 天
双击输入 7
密码长度最小值
8 字符
双击输入 8
密码必须符合复杂性要求
启用
双击选「已启用」
强制密码历史
记住 5 个
双击输入 5
1.3 登录失败锁定 操作路径:secpol.msc → 账户策略 → 账户锁定策略
策略
设置值
账户锁定阈值
3 次无效登录
账户锁定时间
30 分钟
重置账户锁定计数器
30 分钟后
设置锁定阈值后,系统会自动弹出后两项,直接默认即可。
1.4 三权分立账号 操作路径:Win + R → compmgmt.msc → 系统工具 → 本地用户和组 → 用户
右键空白区域 → 新用户,依次创建三个账号:
账号
密码
所属组
Admin_Sys
P@ssw0rd!2026
Administrators
Auditor
P@ssw0rd!2026
Backup Operators(只读)
Inspector
P@ssw0rd!2026
Guests(最小权限)
设置所属组:右键账号 → 属性 → 隶属于 → 添加 → 输入组名 → 确定 Auditor / Inspector 先在 Users 组,再额外加入对应组。
1.5 禁用 Administrator compmgmt.msc → 右键 Administrator → 属性 → 勾选「账户已禁用」
1.6 隐藏上次登录用户名 gpedit.msc → 计算机配置 → Windows 设置 → 安全设置 → 本地策略 → 安全选项
策略
设置
交互式登录:不显示最后的用户名
已启用
1.7 禁用自动登录 gpedit.msc → 计算机配置 → 管理模板 → Windows 组件 → Windows 登录选项
2. 网络与服务 2.1 防火墙配置 操作路径:Win + R → wf.msc
步骤
操作
① 默认规则
入站规则 → 属性 → 公用配置文件 → 入站连接:阻止
② 放行 SSH
新建规则 → 端口 → TCP 10022 → 允许 → 名称「SSH-10022」
③ 放行 RDP
同上,端口 3389,名称「RDP-3389」
④ 限制 IP
新建规则时,远程 IP 地址 → 添加 172.16.11.0/24
⚠️ 先放行 RDP 再操作防火墙,避免断开远程连接。
2.2 禁用默认共享 操作路径:Win + R → regedit
路径:HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
键值
类型
数据
AutoShareWks
REG_DWORD
0
AutoShareServer
REG_DWORD
0
修改后重启 Server 服务或重启服务器。
2.3 修改 RDP 端口 regedit → HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
值名称
类型
原数据
改为
PortNumber
REG_DWORD
3389
13389
重启服务器生效,记得防火墙放行 13389。
2.4 禁用危险服务 操作路径:Win + R → services.msc
服务名
显示名称
操作
RemoteRegistry
Remote Registry
停止 → 禁用
TlntSvr
Telnet
停止 → 禁用
3. 日志与审计 3.1 开启登录审计 secpol.msc → 安全设置 → 本地策略 → 审核策略
策略
设置
审核登录事件
成功 + 失败
审核对象访问
成功 + 失败
3.2 日志保留设置 eventvwr.msc → Windows 日志 → 安全 → 右键属性
设置
值
日志最大大小
512000 KB(500MB)
保留日志方式
按需要覆盖事件
4. Windows 加固小结(检查清单)
三、Linux 服务器安全加固
系统:CentOS 7(为主) / Ubuntu 22.04 ⚠️ 每条命令单独执行,确认无误后再继续下一条 📌 Ubuntu 与 CentOS 不同的地方用 [Ubuntu] 标注
1. 账号与认证 1.1 终端超时自动退出(600 秒 = 10 分钟) 1 echo 'export TMOUT=600' | sudo tee -a /etc/bashrc
[Ubuntu] Ubuntu 路径为 /etc/bash.bashrc
1.2 密码策略 ① 安装密码复杂度模块 1 2 sudo yum install pam_pwquality -y
[Ubuntu] 使用 sudo apt install libpam-pwquality -y
② 配置复杂度要求 1 2 3 4 5 6 7 8 sudo tee /etc/security/pwquality.conf << 'EOF' minlen = 8 dcredit = -1 ucredit = -1 lcredit = -1 ocredit = -1 maxrepeat = 3 EOF
③ 设置密码有效期 1 sudo sed -i 's/^PASS_MAX_DAYS.*/PASS_MAX_DAYS 90/' /etc/login.defs
1 sudo sed -i 's/^PASS_MIN_DAYS.*/PASS_MIN_DAYS 7/' /etc/login.defs
1 sudo sed -i 's/^PASS_MIN_LEN.*/PASS_MIN_LEN 8/' /etc/login.defs
1 sudo sed -i 's/^PASS_WARN_AGE.*/PASS_WARN_AGE 14/' /etc/login.defs
④ 对已有用户设置过期 1 sudo chage -M 90 -m 7 -W 14 <用户名>
1.3 登录失败锁定(3 次失败,锁定 30 分钟) 1 echo 'auth required pam_tally2.so deny=3 unlock_time=1800 onerr=fail' | sudo tee -a /etc/pam.d/system-auth
效果: 3 次登录失败 → 锁定 30 分钟
1 sudo pam_tally2 --user <用户名>
1 sudo pam_tally2 --user <用户名> --reset
[Ubuntu] Ubuntu 路径为 /etc/pam.d/common-auth
1.4 三权分立账号
系统管理员 (admin_sys) / 安全审计员 (auditor) / 日常巡检员 (inspector)
① 创建账号 1 sudo useradd -m -s /bin/bash admin_sys
1 sudo useradd -m -s /bin/bash auditor
1 sudo useradd -m -s /bin/bash inspector
② 设置密码 1 echo 'admin_sys:Sys@Admin2026' | sudo chpasswd
1 echo 'auditor:Aud@itor2026' | sudo chpasswd
1 echo 'inspector:Insp@ctor2026' | sudo chpasswd
③ 分配权限 1 sudo usermod -aG wheel admin_sys
[Ubuntu] Ubuntu 使用 sudo usermod -aG sudo admin_sys
1 sudo usermod -aG adm auditor
inspector 无额外权限,只保留家目录访问
④ 配置 sudo 1 echo 'admin_sys ALL=(ALL) ALL' | sudo tee /etc/sudoers.d/admin_sys
1 echo 'auditor ALL=(ALL) ALL' | sudo tee /etc/sudoers.d/auditor
inspector 不加 sudo,最低权限
1 2 3 id admin_sysid auditorid inspector
1.5 锁定 root 账号
1.6 禁止 SSH 密码登录(改用密钥) ① 确认已配置 SSH 密钥
1 ssh-keygen -t rsa -b 4096
② 将公钥上传到服务器 1 ssh-copy-id admin_sys@服务器IP
③ 修改 SSH 配置(一条一条执行) 1 sudo sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
1 sudo sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
1 sudo sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
1 sudo sed -i 's/^PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
1 sudo sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config
④ 重启 SSH 生效 1 sudo systemctl restart sshd
⚠️ 重启前必须确认密钥能登录!建议多开一个 SSH 窗口测试,不要断开当前连接。
1.7 禁止显示系统信息 1 echo "Authorized users only. All activities are monitored." | sudo tee /etc/issue
1 echo "Authorized users only. All activities are monitored." | sudo tee /etc/issue.net
2. 访问控制 2.1 关键文件权限最小化 1 sudo chmod 600 /etc/shadow
1 sudo chmod 600 /etc/gshadow
1 sudo chmod 600 /etc/passwd-
1 sudo chmod 600 /etc/group-
1 sudo chmod 700 /var/log/audit
1 sudo setfacl -m u:auditor:rx /var/log
1 sudo setfacl -m u:inspector:r /var/log
2.2 关闭不使用的网络服务 1 sudo systemctl status smb 2>/dev/null
1 sudo systemctl stop smb 2>/dev/null; sudo systemctl disable smb 2>/dev/null
1 sudo systemctl status nfs-server 2>/dev/null
1 sudo systemctl stop nfs-server 2>/dev/null; sudo systemctl disable nfs-server 2>/dev/null
3. 网络与服务 3.1 修改 SSH 端口为 10022 1 sudo sed -i 's/^#Port 22/Port 10022/' /etc/ssh/sshd_config
1 sudo sed -i 's/^Port 22/Port 10022/' /etc/ssh/sshd_config
1 sudo systemctl restart sshd
⚠️ 先配防火墙放行新端口再重启 SSH(见 3.2)
3.2 启用防火墙(firewalld) 1 sudo systemctl enable firewalld
1 sudo systemctl start firewalld
1 sudo firewall-cmd --set-default-zone=drop
1 sudo firewall-cmd --zone=public --add-port=10022/tcp --permanent
1 sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
1 sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
1 sudo firewall-cmd --zone=trusted --add-source=172.16.11.0/24 --permanent
1 sudo firewall-cmd --zone=trusted --add-port=10022/tcp --permanent
1 sudo firewall-cmd --reload
1 sudo firewall-cmd --list-all
[Ubuntu] Ubuntu 使用 ufw 而非 firewalld:
1 2 3 4 5 6 sudo ufw allow from 172.16.11.0/24 to any port 10022 proto tcp sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable sudo ufw default deny incoming sudo ufw default allow outgoing
3.3 禁用危险服务 1 sudo systemctl status telnet.socket 2>/dev/null
1 sudo systemctl stop telnet.socket 2>/dev/null; sudo systemctl disable telnet.socket 2>/dev/null
1 sudo systemctl status vsftpd 2>/dev/null
1 sudo systemctl stop vsftpd 2>/dev/null; sudo systemctl disable vsftpd 2>/dev/null
1 sudo systemctl status rsh.socket 2>/dev/null
1 sudo systemctl stop rsh.socket 2>/dev/null; sudo systemctl disable rsh.socket 2>/dev/null
4. 日志与审计 4.1 安装并启用 auditd 1 sudo yum install audit -y
[Ubuntu] 使用 sudo apt install auditd -y
1 sudo systemctl enable auditd
1 sudo systemctl start auditd
4.2 配置关键文件审计 1 sudo auditctl -w /etc/passwd -p wa -k passwd_changes
1 sudo auditctl -w /etc/shadow -p wa -k shadow_changes
1 sudo auditctl -w /etc/sudoers -p wa -k sudoers_changes
1 sudo auditctl -w /var/log -p rwxa -k log_access
1 sudo ausearch -k passwd_changes
4.3 日志保护(chattr 防篡改) 1 sudo chattr +a /var/log/secure
1 sudo chattr +a /var/log/messages
1 sudo chattr +a /var/log/audit/audit.log
1 sudo lsattr /var/log/secure
[Ubuntu] Ubuntu 日志路径不同:/var/log/auth.log 替代 /var/log/secure,/var/log/syslog 替代 /var/log/messages
4.4 日志轮转(保留 6 个月) 1 2 3 4 5 6 7 8 9 10 11 sudo tee /etc/logrotate.d/custom << 'EOF' /var/log/secure { monthly rotate 6 compress delaycompress missingok notifempty create 0640 root utmp } EOF
1 sudo logrotate -d /etc/logrotate.d/custom
[Ubuntu] Ubuntu 日志轮转路径改为 /var/log/auth.log
5. Linux 加固小结(检查清单)
四、安全要求对标表
安全要求
Windows 实现
Linux 实现
交换机实现
身份鉴别(S3)
本地安全策略
/etc/passwd + PAM
本地认证 + SSH
访问控制(S3)
icacls + NTFS 权限
ACL (setfacl) + chattr
ACL 3001/2001
安全审计(S3)
auditpol + Event Log
auditd + rsyslog
日志主机
入侵防范(S3)
Windows Defender + 防火墙
fail2ban + firewalld/ufw
ACL 端口控制
数据保密性(S3)
BitLocker / EFS
LUKS / dm-crypt
SNMPv3 加密
恶意代码防范(S3)
Windows Defender
ClamAV + rkhunter
端口 ACL
五、通用检查清单(速查版) 交换机
Windows 服务器
Linux 服务器
文档版本:v1.0 | 创建:2026-05-29