Skip to content

SSH Tunnel: Port Forwarding

Parameters:

  • -N: Do not execute a remote command.
  • -L [bind_address:]port:host:hostport

Example: Forward server's local postgresql

bash
ssh -N -L 127.0.0.1:15432:localhost:5432 user@server.com

Then localhost:15432 provide the postgresql service

Example: ssh to target server through tunnel server

bash
ssh -N -L 19999:target.com:22 user@tunnel.com

Then link to localhost:19999

Reverse SSH Tunnel

  1. First execute this from target server
bash
ssh -R 19999:localhost:22 source@123.456.789.000
  1. Then execute this from source
bash
ssh -R 19999:localhost:22 source@123.456.789.000

Changelog

Just observe 👀