Skip to content

Instantly share code, notes, and snippets.

@gabehollombe
Created April 23, 2012 04:10
Show Gist options
  • Save gabehollombe/2468822 to your computer and use it in GitHub Desktop.
Save gabehollombe/2468822 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.
host-machine$ ssh -R 55555:localhost:22 myaccount@my_ssh_server.com
connecting-machine$ ssh -L 55555:localhost:55555 myaccount@my_ssh_server.com
connecting-machine$ ssh -p 55555 user_on_host_machine@localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment