Skip to content

Instantly share code, notes, and snippets.

@wey-gu
Last active October 14, 2024 11:32
Show Gist options
  • Save wey-gu/f76eb1b1f5472bf0f89e3d1e3239e715 to your computer and use it in GitHub Desktop.
Save wey-gu/f76eb1b1f5472bf0f89e3d1e3239e715 to your computer and use it in GitHub Desktop.
Expose Local Port to Public Network with SSHD Remote Tunnel
  1. ensure remote server enables remote port fwd on non-loopback ip
#/etc/ssh/sshd_config
GatewayPorts yes
  1. ssh
ssh -R [remote_port]:[destination_address]:[local_port] [username]@[ssh_server]
  1. check listening hosts from remote server

say remote_port is 18000:

$ ss -plunt | grep 18000

Netid         State          Recv-Q          Send-Q                   Local Address:Port                    Peer Address:Port         Process
tcp           LISTEN         0               128                            0.0.0.0:18000                        0.0.0.0:*             users:(("sshd",pid=2714723,fd=10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment