【问题标题】:Augeas - Partial control of sshd-config - Match entriesAugeas - sshd-config 的部分控制 - 匹配条目
【发布时间】:2016-12-03 05:33:28
【问题描述】:

在配置文件 /etc/ssh/sshd_config 中,我想确定一些特定用户(或组)的 PasswordAuthentication 条目,例如:

Match Group xyz_admin, xyz_support
  PasswordAuthentication no
Match User yvonne,yvette
  PasswordAuthentication yes

我不想干预或控制类似但不相关的条目,这些条目可能存在也可能不存在,例如:

Match User xavier
    X11Forwarding yes
Match Group alice
    AllowTcpForwarding yes

以下 Augeas 表达式会创建我需要的条目,但可能会损坏现有的配置条目。

set /files/etc/ssh/sshd_config/Match[1]/Condition/Group "xyz_admin,xyz_support"
set /files/etc/ssh/sshd_config/Match[1]/Settings/PasswordAuthentication "no"
set /files/etc/ssh/sshd_config/Match[2]/Condition/User "yvonne,yvette"
set /files/etc/ssh/sshd_config/Match[2]/Settings/PasswordAuthentication "yes" 

知道如何使这些表达式更具体,以免与任何现有且不相关的“匹配”条目混淆吗?

【问题讨论】:

    标签: match sshd augeas


    【解决方案1】:

    您可以使用Condition/* 子节点过滤掉Match 节点。

    例如,您可以在puppet sshd_config provider(在 Ruby 中)中看到它是如何完成的。请注意,sshd_config 中的所有键都是不区分大小写的,因此您需要使用正则表达式来确保匹配它们而不管它们的大小写。

    【讨论】:

      猜你喜欢
      • 2012-06-05
      • 1970-01-01
      • 2014-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-20
      • 2016-12-29
      • 2020-06-28
      相关资源
      最近更新 更多