#!/usr/bin/env ruby require 'rubygems' require 'net/ssh' hosts = {:diginode2 => {:host => "64.93.11.111", :forwarding => [ {:local_port => 3002, :local_host => "localhost", :remote_port => 3000}, # admin webapp {:local_port => 1936, :local_host => "localhost", :remote_port => 1935}, # fms rtmp {:local_port => 1112, :local_host => "localhost", :remote_port => 1111} # fms admin ] }, :diginode1 => {:host => "64.93.11.112", :forwarding => [ {:local_port => 3000, :local_host => "192.168.19.50", :remote_port => 3000}, # admin app {:local_port => 3001, :local_host => "localhost", :remote_port => 3001}, # admin app {:local_port => 1935, :local_host => "localhost", :remote_port => 1935}, # fms rtmp {:local_port => 1111, :local_host => "localhost", :remote_port => 1111} # fms admin ] }, :diginode3 => {:host => "64.93.11.113", :forwarding => [ {:local_port => 1937, :local_host => "localhost", :remote_port => 1935}, # fms rtmp {:local_port => 1113, :local_host => "localhost", :remote_port => 1111} # fms admin ] }, :record1 => {:host => "64.93.11.211", :forwarding => [ {:local_port => 9001, :local_host => "localhost", :remote_port => 8000} # json rpc ] }, :record2 => {:host => "64.93.11.212", :forwarding => [ {:local_port => 9002, :local_host => "localhost", :remote_port => 8000} # json rpc ] }, :record14 => {:host => "64.93.11.224", :forwarding => [ {:local_port => 9014, :local_host => "localhost", :remote_port => 8000} # json rpc ] } } hosts.each do |name, config| Thread.new { puts "connecting to #{config[:host]}" Net::SSH.start(config[:host], "diginode", :password => "fc8arca#0ne") do |ssh| forwards = config[:forwarding] forwards.each do |f| puts "forwarding #{f[:local_port]}, #{f[:local_host]}, #{f[:remote_port]} from #{config[:host]}" ssh.forward.local(f[:local_port], f[:local_host], f[:remote_port]) end ssh.loop {true} end } end while (true) sleep(0.5) end