2016-07-28 63 views
0

在配置文件/ etc/SSH/sshd_config中我要確定像一些特定用戶的PasswordAuthentication項(或組):Augeas - sshd的,配置的部分控制 - 條目相匹配

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" 

任何想法如何使這些表達式更具體,以避免搞亂任何現有的和無關的「匹配」條目?

回答

0

您可以使用Condition/*子節點來篩選出Match節點。

舉一個例子,你可以看到它是如何在puppet sshd_config provider(在Ruby中)完成的。請注意,sshd_config中的所有密鑰都不區分大小寫,因此無論使用何種情況,都需要使用正則表達式來確保匹配它們。