301 8th Street, San Francisco, CA 94103-4419 (650) 521-7295     contact@inigral.com

SEARCH


   

Archive for July, 2008


Reverse SSH Tunneling

Saturday, July 19th, 2008

Developing a Facebook Platform application from your local machine (with Ruby on Rails)

You have a laptop, a sever and a facebook app.

Ideally, Facebook would talk to your development machine - but what if you don’t have a static ip address and you can’t use dynamic dns or port forwarding?

Reverse SSH Tunneling is what you need my friend.

The following is a step by step tutorial of what you need to do to have ports on your server forwarded to your local machine via ssh.

Step 1: Server Side

Add “GatewayPorts yes” into your sshd_config file:

sudo nano /etc/ssh/sshd_config

– add or edit the GatewayPorts variable, control-O to save, control-X to exit

Reload ssh:

sudo /etc/init.d/ssh reload

Step 2: Your Client

Run the tunnel:

ssh -nNT -g -R 3000:0.0.0.0:3000 me@myserver.com

If you want port 1 on your server to go to port 2 on your local it will look like:
ssh -nNT -g -R 1:0.0.0.0:2 you@yourserver.com so you can forward any port on your server to the standard -p 3000 that your rails server is running on.

Extra-Magic Step: Adding a bit of Rock & Roll

Add an alias to your ~/bash_profile:

alias sshtunnel="ssh -nNT -g -R 3000:0.0.0.0:3000 library@jorgeluisgorgeous.com"

Add your public key to the server for password free login

Thanks to Paul McKeller for getting me started on this