1

I'm using the bert-rpc gem in Ruby 1.9.3 to make calls to an Ernie server that is not on my local network:

BERTRPC::Service.new("www.someurl.com", 9998)

Now I want that connection to be secured via SSH. I was thinking about using a local unix socket, but that means I need to open up the bert-rpc gem code and replace the TCPSocket calls to UnixSocket calls. Isn't there another way?

Isn't it possible to just forward a localhost port 9998 to www.someurl.com 9998, so I can do this:

BERTRPC::Service.new("localhost", 9998)

I've tried the local-to-remote net/ssh examples, but I can't really wrap my head around them, and I can't find any good documentation. Would anybody be so kind to show me an example of how to do the port forwarding?

Thanks

Ronze
  • 1,544
  • 2
  • 18
  • 33

1 Answers1

2

The solution to this was pretty simple. Create a SSH Gateway:

gateway = Net::SSH::Gateway.new('www.someurl.com', 'myuser', :password => "somepass")
gateway.open('www.someurl.com', 9998, 9998)

This routes localhost:9998 to www.someurl.com:9998. This WILL NOT work on Heroku, as Heroku doesn't allow binding on other ports than the assigned $PORT.

Does anyone have an idea on how to make this work on Heroku with a Unix Socket in /tmp?

Ronze
  • 1,544
  • 2
  • 18
  • 33