Sha256: c090c4e46fbe0c08ed983c10d37625fa62d21cafbdadb05c0ea9419bb18c9dd5

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

Port forwarding is a feature of the SSH protocol that allows you to specify a port on one of the hosts, and have network connections on that port forwarded to a port on a different host, using the SSH connection as a proxy. There are basically two ways to use this forwarding:

# A port on the local host is forwarded via the remote host to another machine. Any connection to the specified port will cause all subsequent data to be sent over the connection to the remote host, where it will then be forwarded to the requested destination host.
# A port on the remote host is forwarded over the connection to the local host, and from there to (potentially) some other remote destination. Any connection to the specified port on the remote host is forwarded over the connection to the local host, which then makes a connection to the specified remote destination and sends the data there.

All port forwarding in the Net::SSH library is managed by the @#forward@ service. Just invoke methods on that service to set up any of various port forwarding configurations.

[!figure lang=ruby,number=true,caption=Accessing the #forward service
Net::SSH.start( 'host' ) do |session|
  forward = session.forward
  ...
  session.loop
end
!]

You can define any number of forwards before invoking the main loop, in which case all of those forwards will be handled transparently (and silently) in parallel, over the same connection. (Isn't SSH lovely?)

Naturally, you can also have remote processes, SFTP sessions, and more all working at the same time on the connection.

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
net-ssh-1.0.0 doc/manual/parts/forward_intro.txt
net-ssh-0.9.0 doc/manual/parts/forward_intro.txt