/net-ssh-proxy-gateway

Net::SSH::Proxy compatible SSH-tunneling built on Net::SSH::Gateway

Primary LanguageRubyApache License 2.0Apache-2.0

Build Status Gem Version Yard Docs

Net::SSH::Proxy::Gateway

Allows using Net::SSH::Gateway as a proxy in Net::SSH.start(host, user, proxy:..).

Installation

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

Usage

It accepts the same parameters as Net::SSH::Gateway.new which works quite a lot like Net::SSH.start.

Example

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.

Contributing

Bug reports and pull requests are welcome on GitHub at kontena/net-ssh-proxy-gateway.