管理员密码策略
管理员密码策略
功能简介
从 FortiOS 7.6.5 开始,FortiGate 默认启用并强制执行管理员密码策略。默认要求密码至少有 12 个字符,且大写字母、小写字母、数字和特殊字符各至少有 1 个。7.6.5 之前的版本默认关闭密码策略,可按需启用。
密码范围包含管理员时,策略适用于所有本地管理员,包括内置的 admin。升级到 FortiOS 7.6.5 或更高版本,或新增、调整密码策略后,密码不符合要求的管理员必须在下次登录 GUI 或 CLI 时先修改密码。
相关信息
防火墙本地用户使用独立的密码策略,配置方法参见用户与认证 → 本地用户密码策略。
配置步骤
进入“系统管理 → 设置”,在“安全模式设置”中选择密码范围,设置所需选项,再点击“应用”。

config system password-policy
set status enable
set apply-to admin-password
set minimum-length 12
set min-lower-case-letter 1
set min-upper-case-letter 1
set min-non-alphanumeric 1
set min-number 1
set expire-status enable
set expire-day 90
end
config system admin
edit "admin"
set vdom "root"
set accprofile "super_admin"
set password-expire 2027-02-16 15:02:06
set password ENC PB2jUK0YtQfuqRtRH2NPETApDHco7RqIiZG+BjiXF0sp9bEWCJeSM51zq+MqhWOpgQObut3YLYAZDlwcFqHBZjpSRpdgKScUlpJF+lIk6Rs+2c=
next
end- 密码范围:决定系统密码策略检查哪些密码。在
config system password-policy下通过apply-to设置。- 关闭:停用系统密码策略,对应
set status disable。 - 管理员:仅对本地管理员密码应用策略,对应
set apply-to admin-password。 - IPsec:仅对 IPsec VPN 预共享密钥应用策略,对应
set apply-to ipsec-preshared-key。 - 两者都支持:同时对本地管理员密码和 IPsec VPN 预共享密钥应用策略,对应
set apply-to admin-password ipsec-preshared-key。
- 关闭:停用系统密码策略,对应
- 最小长度:可设为 12 ~ 128。
- 字符要求:启用后,可分别设置密码中以下四类字符的最少个数。
- 大写字母:对应
min-upper-case-letter。 - 小写字母:对应
min-lower-case-letter。 - 数量(0–9):对应
min-number。 - 特殊:指
!、@等非字母、非数字字符,对应min-non-alphanumeric。
- 大写字母:对应
- 密码到期:密码有效期可设为 1 ~ 999 天,默认 90 天。在
config system password-policy中执行set expire-status enable启用密码到期,再用set expire-day <天数>设置有效期。FortiGate 会在config system admin下的admin账号配置中用password-expire记录到期日期和时间。密码到期后,FortiGate 会提示管理员修改密码。
管理员密码复用
- 在 FortiOS 7.6.0 之前,启用管理员密码策略并关闭“允许密码重复使用”后,不能复用最近记录的 3 个密码。
- 从 FortiOS 7.6.0 开始,可以设置历史密码的保留条数和单个历史密码的复用上限。

config system global
set user-history-password-threshold 3
end
config system password-policy
set status enable
set reuse-password enable
set reuse-password-limit 1
end- 密码历史记录阈值(7.6.0 新增):每个本地用户或管理员的历史密码保留上限可设为 3 ~ 15 条,默认 3 条。在
config system global下执行set user-history-password-threshold <条数>设置上限。可在配置备份的pwd-history中查看历史记录。 - 允许密码重复使用:在
config system password-policy下设置。密码范围包含管理员时,此设置适用于所有本地管理员,包括内置的admin。- 关闭:执行
set reuse-password disable,禁止复用已记录的历史密码。 - 无限制:执行
set reuse-password enable,再执行set reuse-password-limit 0(默认配置)。 - 指定(7.6.0 新增):执行
set reuse-password enable,再用set reuse-password-limit <次数>设置同一个历史密码最多可复用几次。CLI 中指定的次数不得大于全局密码历史记录阈值。
- 关闭:执行
- 工作机制:
- FortiGate 将刚换下来的密码放在
pwd-history的首位。历史记录已满时,加入新记录会移除末尾的一条。例如,阈值设为 3,密码从 A 依次改为 B、C、D 后,当前密码是 D,历史记录依次为 C、B、A。再改为新密码 E,历史记录变为 D、C、B,A 从记录中移除。 - 改密时,FortiGate 会检查新密码是否出现在历史记录中。如果该密码已达到复用上限,FortiGate 会拒绝修改。
- 上图中,密码历史记录阈值为
3,复用上限为1。每个账号最多保留 3 条历史密码,记录中的每个密码最多可复用 1 次。
- FortiGate 将刚换下来的密码放在
测试过程
本次测试使用本地管理员 admin。
在 CLI 中启用管理员密码策略,将历史记录阈值设为 3,复用上限设为 1。
config system global set user-history-password-threshold 3 end config system password-policy set status enable set apply-to admin-password set reuse-password enable set reuse-password-limit 1 end确认
admin尚无历史密码。此时管理员配置中没有config pwd-history,当前密码仍是初始密码,以下用<A>表示。config system admin edit "admin" set password ENC <A> next end将初始密码 A 依次改为 B、C,每次修改后用新密码重新登录。
导出配置备份,查看
admin的pwd-history。当前密码是 C,历史记录依次为 B、A。以下示例用占位符替代密码哈希。set reused 0表示这两个密码都未复用过。config system admin edit "admin" config pwd-history edit 1 set password ENC <B> set reused 0 next edit 2 set password ENC <A> set reused 0 next end set password ENC <C> next end提示
pwd-history和reused需要在导出的 FortiOS 格式配置备份中查看,CLI 交互命令行不显示该子表。7.6.0 之前没有reused参数,历史密码保存在管理员账号的history0、history1字段中,同样只在配置备份中可见。reused默认值为0。导出配置时默认值的行会被省略,上面的配置节选显式写出,便于对照测试步骤。
按 C → A → B → C 的顺序改密,A、B、C 各成功复用 1 次。此时导出配置文件并查看
pwd-history,B、A 的reused都是1。C 是当前密码,它在历史记录中的reused仍是上次保存的0。提示
- 复用历史密码后,历史记录仍显示原来的计数。等到成功换成另一个密码,FortiGate 才会将刚换下来的密码在历史记录中的
reused加1。 pwd-history按每个密码最后一次被换下的时间从新到旧排列。下面的输出中,B 排在第一位,因为最后一次改密是从 B 改为 C。
config system admin edit "admin" config pwd-history edit 1 set password ENC <B> set reused 1 next edit 2 set password ENC <A> set reused 1 next edit 3 set password ENC <C> set reused 0 next end set password ENC <C> next end- 复用历史密码后,历史记录仍显示原来的计数。等到成功换成另一个密码,FortiGate 才会将刚换下来的密码在历史记录中的
尝试将当前密码从 C 依次改回 A、B。两个密码都已达到复用上限,FortiGate 拒绝了这两次修改。

FortiGate # config sys admin FortiGate (admin) # edit admin FortiGate (admin) # set password xxxxxxxxxxx Admin password must not be reused too many times. node_check_object fail! for password *将当前密码从 C 改为此前未用过的 D,导出配置文件,再查看
admin的pwd-history。此时 D 是当前密码,C 的reused更新为1,历史记录中的 C、B、A 均显示set reused 1。config system admin edit "admin" config pwd-history edit 1 set password ENC <C> set reused 1 next edit 2 set password ENC <B> set reused 1 next edit 3 set password ENC <A> set reused 1 next end set password ENC <D> next end