Created
December 20, 2012 01:42
-
-
Save granolocks/4342324 to your computer and use it in GitHub Desktop.

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'net/ssh' | |
# Run this on the machine (node) which needs to tunnel out to forward the UI to the remote system (console) | |
Net::SSH.start("remote_host", "remote_user") do |ssh| | |
# since we are running sinatra locally we will forward 43210 on the remote_host to our localhost 4567 | |
# This is effectively the same as: | |
# ssh -R 4567:localhost:43210 remote_user@remote_host | |
ssh.forward.remote(4567, "localhost", 43210) | |
ssh.loop { true } | |
end | |
# If we wanted to actually forward ssh to the remote all we do is change our local port | |
# Net::SSH.start("remote_host", "remote_user") do |ssh| | |
# ssh.forward.remote(22, "localhost", 43210) | |
# ssh.loop { true } | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I created a blogpost out of this...http://www.gabekoss.com/blog/2013/11/ssh_port_forwarding_with_ruby_net_ssh/