]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/portforwarder/templates/authorized_keys.erb
start by quoting strings
[dsa-puppet.git] / modules / portforwarder / templates / authorized_keys.erb
1 <%=
2 config = YAML.load(File.open('/etc/puppet/modules/portforwarder/misc/config.yaml').read)
3 config.each_pair do |sourcehost, services|
4         services.each do |service|
5                 next if service['target_host'] != hostname
6
7                 sshkey = nil
8                 remote_ip = keyinfo[sourcehost][0]['ipHostNumber'].join(',')
9                 forward_to_port = service['target_port']
10                 local_bind = '127.0.0.2'
11
12                 lines << "# from #{sourcehost} on local port #{service['source_bind_port']}"
13                 if remote_ip.nil? or forward_to_port.nil? or local_bind.nil?
14                 #if sshkey.nil? or remote_ip.nil? or forward_to_port.nil? or local_bind.nil?
15                         lines << "# insufficient config values"
16                 else
17                         #lines << "from=\"#{remote_ip}\",command=\"/bin/nc -s #{local_bind} 127.0.0.1 #{forward_to_port}\",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding #{sshkey}"
18                         lines << "#from=\"#{remote_ip}\",command=\"/bin/nc -s #{local_bind} 127.0.0.1 #{forward_to_port}\",no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding <sshkey here>"
19                 end
20         end
21 end
22 lines = []
23 lines.join("\n")
24 %>