3 config = YAML.load(File.open('/etc/puppet/modules/portforwarder/misc/config.yaml').read)
4 config.each_pair do |sourcehost, services|
5 ##lines << "# sourcehost is #{sourcehost}"
6 services.each do |service|
7 ##lines << "# targethost is #{service['target_host']}, my hostname #{hostname}, fqdn is #{fqdn}"
8 next if service['target_host'] != fqdn
11 remote_ip = keyinfo[sourcehost][0]['ipHostNumber'].join(',')
12 forward_to_port = service['target_port']
13 local_bind = '127.0.0.2'
15 lines << "# from #{sourcehost} on local port #{service['source_bind_port']}"
16 if remote_ip.nil? or forward_to_port.nil? or local_bind.nil?
17 #if sshkey.nil? or remote_ip.nil? or forward_to_port.nil? or local_bind.nil?
18 lines << "# insufficient config values"
20 #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}"
21 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>"