Local port forwarding #
ssh -L 8888:127.0.0.1:3306 somebox.example.com
- Expose port
8888on localhost and connect to127.0.0.1on the remote port3306. - This allows you to connect to MySQL on port 8888 locally.
- Instead of
127.0.0.1you can point to any IP address on the network that is reachable.
ssh -NT -L 8888:127.0.0.1:3306 somebox.example.com
- N - Do not execute remote command
- T - Disable pseudo-tty allocation.