5 # Copyright:: 2010, OpenStreetMap Foundation.
6 # Copyright:: 2008-2009, Opscode, Inc.
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # https://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
21 include_recipe "networking"
23 package "openssh-client"
24 package "openssh-server"
27 action [:enable, :start]
28 supports :status => true, :restart => true, :reload => true
31 file "/etc/ssh/ssh_host_dsa_key" do
35 file "/etc/ssh/ssh_host_dsa_key.pub" do
39 hosts = search(:node, "networking:interfaces").sort_by { |n| n[:hostname] }.collect do |node|
40 name = node.name.split(".").first
44 unless node.interfaces(:role => :internal).empty?
45 names.unshift("#{name}.#{node[:networking][:roles][:external][:zone]}.openstreetmap.org")
48 unless node.interfaces(:role => :external).empty?
49 names.unshift("#{name}.openstreetmap.org")
53 "ssh-rsa" => node[:keys][:ssh][:host_rsa_public]
56 if node[:keys][:ssh][:host_ecdsa_public]
57 ecdsa_type = node[:keys][:ssh][:host_ecdsa_type]
59 keys[ecdsa_type] = node[:keys][:ssh][:host_ecdsa_public]
62 if node[:keys][:ssh][:host_ed25519_public]
63 keys["ssh-ed25519"] = node[:keys][:ssh][:host_ed25519_public]
68 :addresses => node.ipaddresses.sort,
73 template "/etc/ssh/ssh_config" do
74 source "ssh_config.erb"
80 template "/etc/ssh/ssh_known_hosts" do
81 source "ssh_known_hosts.erb"
91 firewall_rule "accept-ssh" do
96 dest_ports node[:openssh][:port]