Skip to content

Instantly share code, notes, and snippets.

@brettbuddin
Created April 7, 2010 21:03
Show Gist options
  • Save brettbuddin/359458 to your computer and use it in GitHub Desktop.
Save brettbuddin/359458 to your computer and use it in GitHub Desktop.
Creates a tunnel between a remote server and your local machine. I use this for showing off what's currently in development to outside users. It could also be used for testing against APIs that need to see your machine.
TUNNEL_USERNAME = "deploy"
TUNNEL_HOST = "255.255.255.255"
TUNNEL_PORT = 3000
LOCAL_PORT = 3000
desc "Tunnel to a remote host"
task :tunnel => :environment do
puts "Tunnel established from #{TUNNEL_HOST}:#{TUNNEL_PORT} to 127.0.0.1:#{LOCAL_PORT}"
system "ssh -nNT -g -R *:#{TUNNEL_PORT}:127.0.0.1:#{LOCAL_PORT} #{TUNNEL_USERNAME}@#{TUNNEL_HOST}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment