]> git.openstreetmap.org Git - chef.git/commitdiff
Configure port for sshd
authorTom Hughes <tom@compton.nu>
Fri, 26 Jun 2020 13:26:13 +0000 (14:26 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 26 Jun 2020 13:28:17 +0000 (14:28 +0100)
cookbooks/openssh/recipes/default.rb
cookbooks/openssh/templates/default/sshd_config.conf.erb [new file with mode: 0644]

index 13bc8f517d07a3d4e5897290e172b5397b0ca1eb..78df22c5e418b0930e7d0984e9ff68e6b7377cdf 100644 (file)
@@ -23,6 +23,15 @@ include_recipe "networking"
 package "openssh-client"
 package "openssh-server"
 
+template "/etc/ssh/sshd_config.d/chef.conf" do
+  source "sshd_config.conf.erb"
+  owner "root"
+  group "root"
+  mode 0o644
+  notifies :restart, "service[ssh]"
+  only_if { Dir.exist?("/etc/ssh/sshd_config.d") }
+end
+
 service "ssh" do
   action [:enable, :start]
   supports :status => true, :restart => true, :reload => true
diff --git a/cookbooks/openssh/templates/default/sshd_config.conf.erb b/cookbooks/openssh/templates/default/sshd_config.conf.erb
new file mode 100644 (file)
index 0000000..00a540a
--- /dev/null
@@ -0,0 +1,3 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+Port <%= node[:openssh][:port] %>