Net::SSH::Gateway as a proxy in
Net::SSH.start(host, user, proxy:..).
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install net-ssh-proxy-gateway
session = ::.start( 'target-host-name-or-ip.example.com', 'target-host-username', proxy: ::::::.( 'proxy-host-hostname-or-ip.example.com', 'proxy-host-username', #proxy_host_connection_options (see Net::SSH.start) ) )
Tada! The session to the target host will be tunneled through the proxy host. Nothing else for you to do. The port forwarding will be automatically canceled when the main session is closed.
Bug reports and pull requests are welcome on GitHub at kontena/net-ssh-proxy-gateway.