Skip to content

Instantly share code, notes, and snippets.

@chelsea
Forked from gabehollombe/gist:2468822
Created May 11, 2012 07:59
Show Gist options
  • Save chelsea/2658248 to your computer and use it in GitHub Desktop.
Save chelsea/2658248 to your computer and use it in GitHub Desktop.
SSH tunnel between two NATed machines via a third SSH host
Useful for when you need to have two hosts talk to each other on a specific port but they're both NATed (behind routers).
For example, you want to be able to SSH into your friend's machine to pair program with them.
remote$ ssh -R 55555:localhost:22 myaccount@my_ssh_server.com
local$ ssh -L 55555:localhost:55555 myaccount@my_ssh_server.com
local$ ssh -p 55555 localhost -l remote_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment