Skip to content

Instantly share code, notes, and snippets.

@pogodan
Created May 3, 2011 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pogodan/952951 to your computer and use it in GitHub Desktop.
Save pogodan/952951 to your computer and use it in GitHub Desktop.
thor/pow reverse SSH tunnel
class Tunnel < Thor
method_options :environment => "development", :aliases => "-e", :desc => "Config environment"
desc "start", "Start an ssh tunnel"
def start
command = "ssh -nNT -g -R *:#{tunnel['public_port']}:0.0.0.0:#{tunnel['local_port']} #{tunnel['username']}@#{tunnel['public_host']}"
puts "executing #{command}"
exec command
end
private
def tunnel
@tunnel ||= YAML.load_file(File.expand_path('~/.tunnel.yml'))[options[:environment]]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment