Quick Linux Tip #39:
Try: ssh -L 3307:db-internal:3306 -N -f linuxteck@jumphost
Info: -L local_port:target_host:target_port forwards local traffic through SSH to a remote server. -N skips the remote shell, and -f sends SSH to the background.
Examples:
- $ ssh -L 8080:localhost:80 user@server # Access remote web app locally
- $ ssh -R 9000:localhost:9000 user@server # Expose local port on remote server
- $ ssh -D 1080 user@server # Dynamic SOCKS proxy for web traffic
Note: Kill active background tunnels with pkill -f 'ssh -L 3307'. Add -o ExitOnForwardFailure=yes so SSH fails immediately if the local port is already bound.
Leave a Reply