Net::SSH is a Ruby implementation of the SSH2 client protocol.
http://rubyforge.org/projects/net-ssh
You asked for it, and you got it! Version 0.0.3 now supports port forwarding. You can enable forwarding both from local to remote ports, and vice versa (corresponding to the -L and -R options of ssh). Also, you can programmatically mimic connection to/from ports, using handler objects.
Here's a quick demo of port forwarding:
Net::SSH.start( 'localhost' ) do |session|
manager = Net::SSH::Service::PortForwardManager.new( session )
manager.forward_local( 12345, 'www.yahoo.com', 80 )
manager.forward_local( 12346, 'www.google.com', 80 )
session.main_loop { true }
end
See the "examples" subdirectory for more examples.
This release also allows clients to specify their preferred SSH algorithms. This means you can (for example) enable zlib compression of the data stream. See the examples subdirectory for an example of how to do this.
A few other fixes have been made, though the code is still far from perfect, or complete. More work needs to be done on:
- increasing the coverage of the SFTP protocol
- supporting ssh-agent if one is running
- supporting private keys with key/value pairs in their headers
- implementing a synchronous version of Net::SSH::Session
Try it out and let me know what you like/don't like. Wishlists are accepted, as well. As usual, any version of Ruby < 1.8.2 will need to have the patched version of OpenSSL, also available from the Net::SSH downloads page.
···
--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis
"I use octal until I get to 8, and then I switch to decimal."