How can the Address condition in a Match conditional block in sshd_config be negated?

Osw*_*ald 7 ssh cygwin-sshd

当用户通过 SSH 从我的 LAN 外部登录到我的 LAN 时,我想强制用户输入特定命令。我的想法是,ForceCommandMatch条件块中使用,匹配除 LAN 中的地址之外的所有地址。

我已经尝试了以下,根据man 5 sshd_config

  • Match Address !192.168.1.0/24 允许用户从任何地方执行任何命令。
  • Match Address !192.168.* 允许用户从任何地方执行任何命令。
  • Match !Address 192.168.*通过sshd拒绝启动来阻止任何命令的执行。

(“模式”部分)中!描述了使用否定模式。这如何应用于地址?man 5 ssh_config

mgo*_*ven 10

根据此 ServerFault answer,出于某种未知原因,您需要添加通配符匹配才能执行此操作。然而,CIDR 表示法似乎有效。例如:

Match Address *,!192.168.1.0/24
    ForceCommand /bin/false
Run Code Online (Sandbox Code Playgroud)

这适用于 OpenSSH 5.9p1。