CLI 权限
CLI 权限
管理员权限配置(Admin Profile)决定账户能够查看和修改哪些功能,以及能够使用哪些 CLI 命令。同一台 FortiGate 上,不同账户登录后可用的命令可能不同。遇到命令不显示、无法修改配置或升级后不能执行诊断命令时,应先检查账户绑定的权限配置和 VDOM 范围。
权限范围
功能区域权限
管理员账户在 config system admin 中通过 accprofile 引用权限配置。权限配置位于 config system accprofile,按系统、网络、防火墙、VPN、日志等功能区域分配访问权限。
CLI 语法示例,常见字段包括 sysgrp(系统)、netgrp(网络)、fwgrp(防火墙)、vpngrp(VPN)和 loggrp(日志)。例如,set fwgrp read 允许读取防火墙配置,但不允许创建或修改地址对象、防火墙策略:
config system accprofile
edit "<profile_name>"
set sysgrp {none | read | read-write | custom}
set netgrp {none | read | read-write | custom}
set fwgrp {none | read | read-write | custom}
set vpngrp {none | read | read-write}
set loggrp {none | read | read-write | custom}
next
end| 权限值 | 含义 | CLI 使用范围 |
|---|---|---|
none | 无访问权限 | 不能访问对应功能区域 |
read | 只读 | 可以查看对应区域的配置,不能修改 |
read-write | 读写 | 可以查看并修改对应区域的配置 |
custom | 自定义 | 支持该选项的功能区域可以继续细分子项权限 |
CLI 命令类别权限
从 FortiOS 7.4.2 开始,管理员权限配置增加了对 CLI 命令类别的独立控制。即使某个功能区域已经设置为 read-write,对应 CLI 类别未启用时,管理员仍无法通过 CLI 执行该类命令。
CLI 语法示例,每个命令类别分别选择 enable 或 disable:
config system accprofile
edit "<profile_name>"
set cli-get {enable | disable}
set cli-show {enable | disable}
set cli-config {enable | disable}
set cli-exec {enable | disable}
set cli-diagnose {enable | disable}
next
end| 参数 | 控制的命令类别 | 常见用途 |
|---|---|---|
cli-get | get | 查看运行状态或配置值 |
cli-show | show | 查看配置内容 |
cli-config | config | 进入配置层级并执行配置操作 |
cli-exec | execute | 执行 Ping、Traceroute 等操作命令 |
cli-diagnose | diagnose | 执行诊断、调试等命令 |
重要
cli-diagnose enable允许使用诊断命令类别,不会自动授予对应功能区域的读写权限。只读管理员可以使用部分诊断命令,另一些对设备执行操作的诊断命令仍需要对应功能区域的读写权限。- 禁用
cli-config只限制 CLI 命令类别。如果需要同时禁止通过 GUI 修改配置,还应将相应功能区域设置为read。
VDOM 范围
多 VDOM 环境中,管理员的权限还受到可管理 VDOM 的限制,VDOM 管理员只能管理被分配的 VDOM。
检查权限时,应同时确认账户的 accprofile、vdom,以及当前 CLI 所处的全局或 VDOM。
config system admin
edit "branch_admin"
set accprofile "prof_admin"
set vdom "branch"
set password ENC xxxxxxxxxxx
next
endsuper_admin
super_admin 是内置的完整管理权限,默认 admin 账户使用该权限。它可以查看和修改 FortiGate 配置及其他管理员账户,且该权限配置不能修改或删除。
prof_admin或自定义权限配置即使将所有功能区域设为读写,也不等同于super_admin。部分管理操作仍要求super_admin。- 修改 CLI 权限开关时,使用具有
super_admin权限的账户。受限管理员不能通过修改自身正在使用的权限配置来提升权限。 - 日常巡检和分工管理使用满足工作范围的自定义权限配置。排障需要额外权限时,确认具体命令及其影响后再授权。
相关信息
管理员账户和权限配置方法参见系统管理 → 管理员配置 → 管理员设置。
配置方法
查看账户与权限配置
使用
super_admin账户登录,查看目标管理员引用的权限配置。示例中的cli_monitor为已存在的管理员账户。FortiGate # show system admin cli_monitor config system admin edit "cli_monitor" set accprofile "cli_readonly" set vdom "root" set password ******** next end相关信息
set accprofile "cli_readonly":账户引用的权限配置为cli_readonly。set vdom "root":账户被分配到rootVDOM。
查看该权限配置的完整内容,确认功能区域权限和 CLI 类别开关。
FortiGate # show full-configuration system accprofile cli_readonly config system accprofile edit "cli_readonly" set comments '' set scope vdom set secfabgrp none set ftviewgrp none set authgrp none set sysgrp read set netgrp read set loggrp read set fwgrp read set vpngrp none set utmgrp none set wanoptgrp none set wifi none set admintimeout-override disable set cli-diagnose disable set cli-get enable set cli-show enable set cli-exec disable set cli-config disable set system-execute-ssh enable set system-execute-telnet enable next end提示
sysgrp、netgrp、loggrp和fwgrp为read,表示对应功能区域只读。cli-get、cli-show为enable,表示允许使用这两类查看命令。cli-config、cli-exec和cli-diagnose为disable,表示禁止配置、操作和诊断命令类别。- 其余功能区域为
none,没有额外开放 VPN、安全配置等功能的访问权限。 system-execute-ssh和system-execute-telnet是独立的跳板控制参数。这里虽然保留为enable,但cli-exec disable已禁止整个execute命令类别。- 多 VDOM 模式下,使用全局管理员进入
config global后检查管理员及权限配置。
配置只读巡检权限
以下配置示例适用于 FortiOS 7.4.2 及以上版本。目标是允许账户查看系统、网络、防火墙和日志配置,禁止通过 CLI 修改配置、执行操作命令和运行诊断命令。
使用
super_admin新建权限配置cli_readonly,显式指定功能区域和 CLI 类别权限。config system accprofile edit "cli_readonly" set sysgrp read set netgrp read set fwgrp read set loggrp read set cli-get enable set cli-show enable set cli-config disable set cli-exec disable set cli-diagnose disable next end将已存在的管理员账户
cli_monitor绑定到该权限配置,并将其管理范围设为rootVDOM。config system admin edit "cli_monitor" set accprofile "cli_readonly" set vdom "root" next end使用
cli_monitor新建登录会话,按下表检查授权范围。检查命令 预期结果 get system status可以查看系统状态 show firewall address可以查看当前授权 VDOM 内的地址对象配置 config firewall address不允许进入配置层级 execute ?无法获得可用的操作命令列表 diagnose ?无法获得可用的诊断命令列表
只读权限下使用诊断命令
诊断命令类别开关与功能区域权限共同决定可用命令。即使启用了 cli-diagnose,只读权限也不能满足部分诊断命令的要求。例如,diagnose radiustest 需要 User & Device 类别的读写权限,diagnose forticlient 需要 VPN 类别的读写权限。
只读账户也可以按需开放诊断命令类别。例如,将系统、网络、日志和防火墙区域设为 read,同时启用 cli-diagnose、cli-get 和 cli-show。
config system accprofile
edit "cli_readonly"
set sysgrp read
set netgrp read
set loggrp read
set fwgrp read
set cli-diagnose enable
set cli-get enable
set cli-show enable
next
end使用该权限配置,账户可以使用 diagnose sys session 下的查询命令,但不能执行清除会话的 diagnose sys session clear。启用诊断命令类别不会解除具体子命令的读写权限限制。
常见问题
升级后 diagnose 命令不可用
FortiOS 7.2 使用 system-diagnostics 控制诊断命令权限。从 FortiOS 7.4.2 开始,该参数更名为 cli-diagnose,除 super_admin 外默认禁用。跨越该版本边界升级时,即使此前启用了 system-diagnostics,也需要重新检查诊断权限。
从 FortiOS 7.4.1 或更早版本升级到 7.4.2 及以上版本时,CLI 类别开关按以下状态应用。
| 参数 | 升级时应用的状态 |
|---|---|
cli-get | enable |
cli-show | enable |
cli-config | enable |
cli-exec | enable |
cli-diagnose | disable |
受影响账户执行诊断命令时可能看到以下现象。
FortiGate $ diagnose debug enable
Unknown action 0由 super_admin 检查账户绑定的权限配置,按需启用 cli-diagnose,再使用目标账户重新登录复测。
功能权限已设为读写,仍不能执行配置
功能区域的 read-write 与 cli-config 是分别检查的。遇到 GUI 可以修改、CLI 中却没有 config 等命令时,应由 super_admin 检查对应的 CLI 类别开关,不要只检查功能区域是否全部设为读写。
如果命令类别已经启用,但只有某个子命令不可用,还应检查该功能的读写权限、VDOM、型号和 FortiOS 版本。
修改 cli-diagnose 返回 -672
受限管理员尝试修改自身正在使用的权限配置时,可能在提交配置时返回 -672。例如,管理员 ops_admin 绑定自定义权限配置 ops_profile,该配置的功能区域已设为读写,并启用了 cli-config,但未启用 cli-diagnose。
使用
ops_admin登录,进入自身绑定的权限配置,尝试启用诊断命令。执行set cli-diagnose enable后,在next提交时返回错误,设置被丢弃。FortiGate $ config system accprofile FortiGate (accprofile) $ edit "ops_profile" FortiGate (ops_profile) $ set cli-diagnose enable FortiGate (ops_profile) $ next object set operator error, -672 discard the setting Command fail. Return code 1 FortiGate (accprofile) $切换到另一个具有
super_admin权限的账户,为同一个权限配置启用诊断命令并保存。FortiGate # config system accprofile FortiGate (accprofile) # edit "ops_profile" FortiGate (ops_profile) # set cli-diagnose enable FortiGate (ops_profile) # next FortiGate (accprofile) # end FortiGate #功能区域全部设为
read-write,也不能授权管理员自行提升其正在使用的权限配置。该错误应由另一个具有super_admin权限的账户处理。