Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 使用工具修改ssh_配置_Linux_Bash_Puppet_Augeas - Fatal编程技术网

Linux 使用工具修改ssh_配置

Linux 使用工具修改ssh_配置,linux,bash,puppet,augeas,Linux,Bash,Puppet,Augeas,这是默认值,其中包含#ForwardX11 no,我想更改它,所以我这样做了 augtool set "/files/etc/ssh/ssh_config/ForwardX11" yes 失败,但这会在主机* augtool set "/files/etc/ssh/ssh_config/Host/ForwardX11" yes 问题 为什么不augtool取消注释#ForwardX11 no 为什么我必须指定../Host/… 为什么下面的输出中缺少GSSAPIAuthentication

这是默认值,其中包含
#ForwardX11 no
,我想更改它,所以我这样做了

augtool set "/files/etc/ssh/ssh_config/ForwardX11" yes
失败,但这会在主机*

augtool set "/files/etc/ssh/ssh_config/Host/ForwardX11" yes
问题

  • 为什么不
    augtool
    取消注释
    #ForwardX11 no
  • 为什么我必须指定
    ../Host/…
  • 为什么下面的输出中缺少
    GSSAPIAuthentication yes
    ForwardX11Trusted yes
Augeas没有(联合国)评论的概念。它只允许您使用映射它们的树来管理文件中的条目。您可以通过在注释之后(或之前)插入新条目并删除注释来模拟取消注释条目,但Augeas不会自动执行此操作

当Augeas设置一个值时,如果可以找到一个现有节点,它将更改该节点的值,否则将创建一个新节点(在树的末尾)。但是,树中节点的顺序很重要,在
主机
节点之后为全局设置创建条目是无效的。因此,您需要在第一个
主机
条目之前插入新节点:

ins ForwardX11 before Host[1]
set ForwardX11 yes
如果愿意,您也可以在
主机
条目中设置它,尽管这不是严格等效的(请参见
manssh\u config
):


至于缺少的两个条目,它们不会出现在输出中,因为
ls
不是递归命令。如果您想递归地查看树,请使用
print

非常感谢!有没有办法在主机[1]之前
ins ForwardX11
和从命令行
设置ForwardX11 yes
,这样我就可以编写脚本了?您可以将这两个命令放在一个文件中,并使用
augtool-f
运行它。请记住树中的插入不是幂等的,因此最好使用某种绑定(Ruby、Perl、PHP等)
ins ForwardX11 before Host[1]
set ForwardX11 yes
set Host[.='*'] *    # Ensure the Host entry exists
set Host[.='*']/ForwardX11 yes