SSH tunnels allow you to forward traffic between your local machine and a remote server or its internal network.
# Local Forwarding (-L): Local port -> Remote target
# Access http://localhost:8080 to reach http://10.0.0.5:80 via jump-host
ssh -L 8080:10.0.0.5:80 user@jump-host
# Remote Forwarding (-R): Remote port -> Local target
# Expose local port 3000 to the remote server's port 9000
ssh -R 9000:localhost:3000 user@server
# Dynamic Forwarding (-D): SOCKS5 Proxy
ssh -D 1080 user@host
# Use with curl: curl --socks5 127.0.0.1:1080 https://www.google.com
# Background tunnel without shell
ssh -CNfg -L 3306:db.internal:3306 jump
# -C: compress, -N: no command, -f: background, -g: allow other machines to connect