依据 GB/T 22239-2019《信息安全技术 网络安全等级保护基本要求》等保2.0三级 标准,针对 Debian Linux(12/11/10 版本) 给出可直接落地的测评命令清单。
覆盖身份鉴别、访问控制、安全审计、入侵防范、恶意代码防范等核心控制点,并结合 Debian 特有机制(如 AppArmor/SELinux、Apt 包管理、Systemd)进行优化调整。
一、身份鉴别(8.1.4.1)
1.1 账户唯一性与密码复杂度
Debian 特有配置:
# 查看默认启用的密码复杂度模块(Debian 12默认使用pam_pwquality)
cat /etc/pam.d/common-password |grep-E"pam_pwquality|pam_cracklib"
# 安装并配置密码复杂度(如未安装)
sudoaptinstall libpam-pwquality -y
# 合规配置示例(/etc/security/pwquality.conf)
minlen =8
minclass =3
maxrepeat =2
dcredit =-1
ucredit =-1
lcredit =-1
ocredit =-1
# 要求:至少8位,包含3种字符类型(大写、小写、数字、特殊字符选3)
1.2 登录失败处理与会话超时
Debian 登录失败锁定配置:
# Debian 12推荐使用pam_faillock(替代旧的pam_tally2)
grep-E"pam_faillock" /etc/pam.d/common-auth /etc/pam.d/common-account
# 配置示例(/etc/pam.d/common-auth):
auth required pam_faillock.so preauth silent audit deny=5unlock_time=300
auth [default=die] pam_faillock.so authfail audit deny=5unlock_time=300
# 查看失败锁定状态
faillock --user username
faillock --user username --reset# 手动解锁
1.3 远程管理安全
# 确认SSH服务运行
systemctl status ssh
# 检查SSH安全配置(Debian默认已较安全)
cat /etc/ssh/sshd_config |grep-E'PermitRootLogin|Protocol|PubkeyAuthentication|PasswordAuthentication'
# 合规要求:PermitRootLogin no、Protocol 2、PubkeyAuthentication yes、PasswordAuthentication no(或yes但配合密钥)
# 确认未开放Telnet
ss -tuln|grep':23'
# 检查SSH版本(Debian 12默认OpenSSH 9.x)
ssh-V
高风险项 :使用Telnet或允许root远程登录,直接判定不符合三级要求。
1.4 双因子认证(高风险项)
测评方法:
# 检查SSH公钥认证配置
grep"PubkeyAuthentication yes" /etc/ssh/sshd_config
# 检查PAM模块是否集成双因子
cat /etc/pam.d/sshd |grep-E"pam_google_authenticator|pam_u2f|pam_pkcs11"
# 安装Google Authenticator示例
sudoaptinstall libpam-google-authenticator -y
# 查看证书存储(如使用智能卡)
ls /etc/pki/nssdb/ 2>/dev/null ||echo"未配置PKI"
dpkg -l|grep-E"opensc|libpam-pkcs11"