Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'net/ssh/gateway'
- s1 = {:host=>'foo', :user => 'foobar', :options => {:password => 'barfoo', :port => 2221}}
- s2 = {:host=>'bar', :user => 'foobar', :options => {:password => 'barfoo', :port => 2222}}
- s3 = {:host=>'baz', :user => 'foobar', :options => {:password => 'barfoo', :port => 2223}}
- s4 = {:host=>'moo', :user => 'foobar', :options => {:password => 'barfoo', :port => 2224}}
- gw = Net::SSH::Gateway.new(s[:host], s[:user], s[:options)
- gw_port = gw.open(s2[:host], s2[:port])
- gw2 = Net::SSH::Gateway.new(s2[:host], s2[:user], s[:options].merge({:port => gw_port}))
- gw2_port = gw2.open(s3[:host], s3[:port])
- gw3 = Net::SSH::Gateway.new(s3[:host], s3[:user], s[:options].merge({:port => gw2_port}))
- gw3.ssh(s4[:host], s4[:user], , s[:options]) do |session|
- session.exec!('uptime')
- end
- gw2.shutdown!
- gw.shutdown!
Add Comment
Please, Sign In to add comment