Allows using Net::SSH::Gateway
as a proxy in Net::SSH.start(host, user, proxy:..)
.
Add this line to your application's Gemfile:
gem 'net-ssh-proxy-gateway'
And then execute:
$ bundle
Or install it yourself as:
$ gem install net-ssh-proxy-gateway
It accepts the same parameters as Net::SSH::Gateway.new
which works quite a lot like Net::SSH.start
.
session = Net::SSH.start(
'target-host-name-or-ip.example.com',
'target-host-username',
proxy: Net::SSH::Proxy::Gateway.new(
'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.