SSH – Difference Between -L and -R Options

linuxportport-forwardingsshssh-tunnel

I looked at the ssh manual (man ssh) and read the definitions for -L and -R option but don't quite understand the difference. Both seem capable of forwarding requests to a desired host and port. Can someone trying explaining the difference to a kid… What's the primary different between the two options?

Best Answer

It's right there, in the man page:

-L
Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side.

-R
Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side.

(highlighting by me)

The difference is the direction. -L forwards local to remote, -R the reverse.