Skip to content

Instantly share code, notes, and snippets.

@granolocks
Created December 20, 2012 01:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save granolocks/4342324 to your computer and use it in GitHub Desktop.
Save granolocks/4342324 to your computer and use it in GitHub Desktop.
:feelsgood:
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
@granolocks
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment