Skip to content

Instantly share code, notes, and snippets.

@rponte
Last active September 26, 2023 23:04
Show Gist options
  • Save rponte/6417582 to your computer and use it in GitHub Desktop.
Save rponte/6417582 to your computer and use it in GitHub Desktop.
Opening a SSH tunnel
# ssh -L <local_port>:<remote_ip>:<remote_port> <user>@<gateway_ip>
ssh -L 1433:192.168.1.4:1433 owner@google.com
# or if you want to run in background without tty
ssh -f -N -T -L 8080:localhost:80 owner@google.com
@rponte
Copy link
Author

rponte commented Sep 2, 2013

@rponte
Copy link
Author

rponte commented Feb 13, 2015

More information about the arguments,
http://unix.stackexchange.com/questions/46235/how-does-reverse-ssh-tunneling-work

The other options are:

  • -f tells ssh to background itself after it authenticates, so you don't have to sit around running something on the remote server for the tunnel to remain alive.
  • -N says that you want an SSH connection, but you don't actually want to run any remote commands. If all you're creating is a tunnel, then including this option saves resources.
  • -T disables pseudo-tty allocation, which is appropriate because you're not trying to create an interactive shell.

@rponte
Copy link
Author

rponte commented Sep 26, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment