ssh - 如何使用 puppet 模块修改 SSH 配置文件

标签 ssh configuration puppet

我正在尝试修改 SSH 配置文件以删除 arcfour , arcfour 128arcfour 256 /etc/ssh/sshd_config 中的算法在 186 台使用 puppet 的 linux 服务器上。基本上,我正在查找和替换以删除 sshd_config 中的这三种算法类型。文件。我创建了一个名为 SSH_Test 的模块我想知道我的下一步是什么。我想我可以使用这些资源,但我不确定将它们放在哪里,我不确定它们是否正确

file_line { 'Ciphers':
  path  => '/etc/ssh/sshd_config',
  line  => 'arcfour, arcfour128, arcfour256',
  match => '',
}

来自以下评论的新配置
node default { 
  file { '/etc/motd':
    owner => 'root',
    group => 'root',
    mode => '0644',
    content => "\nAll hail the knife crab\n"
  }
}

最佳答案

遵循 file_line 的文档此处提供:https://forge.puppet.com/puppetlabs/stdlib/types

我们有以下资源:

file_line { 'Ciphers':
  ensure            => absent,
  path              => '/etc/ssh/sshd_config',
  match             => '.*arcfour.*',
  multiple          => true,
  match_for_absence => true,
}
ensure删除行,path对于指定的文件,match用于匹配正则表达式的行,multiple因为您希望它作用于文件中的多行,并且 match_for_absence以便在匹配时删除行。

如果您使用 Puppet >= 4.0 或 3.8 和 future 的解析器,那么可以使用 lambda 使这更精确和更清晰。如果你是,请告诉我。

关于ssh - 如何使用 puppet 模块修改 SSH 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39877334/

相关文章:

git - 简单的 Github 提交不起作用(尝试将图像添加到我的公共(public)图像文件夹)

parsing - 使用 lex/yacc (或 flex/bison)对于配置文件解析来说是一种过度杀伤力吗?

postgresql - 在 Play 上配置 PostgreSQL! 2.6

puppet :Hiera 不喜欢任何子目录

python - 类似 python 的 puppet 语法

ssh - 如何在没有密码的情况下通过 SSH 登录

linux - 无法从一个 AMI ec2 实例连接到另一实例

linux - 通过 SSH 远程运行脚本

ruby-on-rails - 忽略 rails 项目中的 .gitignore config/database.yml

vagrant - 如何从本地VirtualBox/Vagrant开发环境完成生产部署?