Skip to content

Instantly share code, notes, and snippets.

@hongry18
Last active February 12, 2018 07:39
Show Gist options
  • Save hongry18/7f85204f032efb5cc207b2a3a0655603 to your computer and use it in GitHub Desktop.
Save hongry18/7f85204f032efb5cc207b2a3a0655603 to your computer and use it in GitHub Desktop.
ssh.tunneling.md

SSH Tunneling

  • -L Option: Local Port Forwarding
  • -R Option: Remote Port Forwarding
  • -N: Do not execute a remote command

command

create single tunnel

ssh -N -LPort:host:Port2 user@host
ssh -N -RPort:host:Port2 user@host

create multiple tunnel

[user@local] ssh -L30001:localhost:30001 user@host1
[user@host1] ssh -L30001:localhost:30001 user@host2
[user@host2] ssh -L30001:localhost:22 user@host3

# single command
ssh -v -L30001:localhost:30001 user@host1 -t ssh -v -L30001:localhost:30001 user@host2 -t ssh -v -L30001:localhost:22 user@host1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment