Net::SSH and port forwarding

Discussion in 'Ruby' started by Jamis Buck, Jul 6, 2004.

  1. Jamis Buck

    Jamis Buck Guest

    Looks like the local->remote port forwarding will be pretty easy to
    implement (I've already got a prototype that does the trick...messily).

    At any rate, I'm looking at this and I'm realizing that because I'm
    doing this all in Ruby, you could concievably have the port forwarding
    do tricks based on additional information in the request. Here's a use
    case to clarify my meaning:

    Set up port forwarding on port X. When a connection is recieved, parse
    the request. If the request matches format A, forward the request to
    boxA:portA. If the request matches format B, forward the request to
    boxB:portB. Etc. All of this happens transparently to the client that
    connected to the local port.

    Would this be useful for anyone? I'm probably going to write the Ruby
    interface in such a way that you could do something like the above with
    minimal effort, but I'm just curious if anyone would actually use such a
    feature in practice. :)

    --
    Jamis Buck

    http://www.jamisbuck.org/jamis

    ruby -ropenssl
    -e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,false,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'
    Jamis Buck, Jul 6, 2004
    #1
    1. Advertising

  2. Jamis Buck

    Dick Davies Guest

    * Jamis Buck <> [0736 17:36]:

    > Set up port forwarding on port X. When a connection is recieved, parse
    > the request. If the request matches format A, forward the request to
    > boxA:portA. If the request matches format B, forward the request to
    > boxB:portB. Etc. All of this happens transparently to the client that
    > connected to the local port.


    > Would this be useful for anyone?


    It would save you having to open multiple tunnels, at least in theory,
    which would be very handy in a lot of circumstances.

    If you could daemonize that you'd have an stunnel killer...

    > ruby -ropenssl
    > -e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,false,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'
    >


    --
    Life is like a simile.
    Rasputin :: Jack of All Trades - Master of Nuns
    Dick Davies, Jul 7, 2004
    #2
    1. Advertising

  3. Jamis Buck

    Jamis Buck Guest

    Dick Davies wrote:
    > * Jamis Buck <> [0736 17:36]:
    >
    >
    >>Set up port forwarding on port X. When a connection is recieved, parse
    >>the request. If the request matches format A, forward the request to
    >>boxA:portA. If the request matches format B, forward the request to
    >>boxB:portB. Etc. All of this happens transparently to the client that
    >>connected to the local port.

    >
    >
    >>Would this be useful for anyone?

    >
    >
    > It would save you having to open multiple tunnels, at least in theory,
    > which would be very handy in a lot of circumstances.
    >


    Actually, this is something you wouldn't be able to do even with
    multiple tunnels, since you're still binding to a single port on the
    localhost. You're just forwarding from that one port to multiple
    different remote hosts, based on the format of the request.

    As I said, it sounds cool, but I wonder how useful it would be in
    practice. It should be in the next version of Net::SSH, regardless. :)

    --
    Jamis Buck

    http://www.jamisbuck.org/jamis

    "I use octal until I get to 8, and then I switch to decimal."
    Jamis Buck, Jul 7, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Navic
    Replies:
    2
    Views:
    2,575
  2. Jesse Rosenthal

    Background process for ssh port forwarding

    Jesse Rosenthal, Oct 2, 2005, in forum: Python
    Replies:
    1
    Views:
    524
    Juho Schultz
    Oct 4, 2005
  3. Jesse Rosenthal

    Background process for ssh port forwarding

    Jesse Rosenthal, Nov 15, 2005, in forum: Python
    Replies:
    0
    Views:
    343
    Jesse Rosenthal
    Nov 15, 2005
  4. Andrew Tomazos
    Replies:
    5
    Views:
    572
  5. Replies:
    0
    Views:
    93
Loading...

Share This Page