DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Reverse SSH Tunnel
Create a Reverse SSH Tunnel back to you development application from a public facing server.
In config/tunnel.yml
development: public_host_username: SSH_USERNAME public_host_password: SSH_PASSWORD public_host: SSH_SERVER_HOST_NAME public_port: 8868 local_port: 3000
In lib/tasks/tunnel.rake
namespace :tunnel do
desc "Start a ssh tunnel"
task :start => :environment do
SSH_TUNNEL = YAML.load_file("#{RAILS_ROOT}/config/tunnel.yml")[RAILS_ENV]
public_host_username = SSH_TUNNEL['public_host_username']
public_host = SSH_TUNNEL['public_host']
public_port = SSH_TUNNEL['public_port']
local_port = SSH_TUNNEL['local_port']
puts "Starting tunnel #{public_host}:#{public_port} \
to 0.0.0.0:#{local_port}"
exec "ssh -nNT -g -R *:#{public_port}:0.0.0.0:#{local_port} \
#{public_host_username}@#{public_host}"
end
end






Comments
Snippets Manager replied on Mon, 2009/01/05 - 7:46pm