Forward connections to client localhost:8080 to internal.example.test:80, which is reachable from the SSH server.
The SSH server is gateway.example.test.
Which specification is appropriate?
-L local_port:destination:destination_port forwards a local listener through the SSH server.
Detailed explanation
ssh -L 8080:internal.example.test:80 trainee@gateway.example.testCorrect. -L forwards a client-side port to a destination reachable through the SSH server.
Correct. -L forwards a client-side port to a destination reachable through the SSH server.
ssh -R 8080:internal.example.test:80 trainee@gateway.example.testIncorrect. -R creates a listener on the remote side, opposite to the local-listener requirement.
Incorrect. -R creates a listener on the remote side, opposite to the local-listener requirement.
ssh -D 8080:internal.example.test:80 trainee@gateway.example.testIncorrect. -D creates a SOCKS proxy rather than a fixed-destination forward.
Incorrect. -D creates a SOCKS proxy rather than a fixed-destination forward.
ssh -p 8080 internal.example.test:80 trainee@gateway.example.testIncorrect. -p selects the SSH server port; it does not specify a forwarding destination.
Incorrect. -p selects the SSH server port; it does not specify a forwarding destination.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s\n' 'ssh -L 8080:internal.example.test:80 trainee@gateway.example.test'Expected result
ssh -L 8080:internal.example.test:80 trainee@gateway.example.testKey points
- -L
- -R
- -D
- Forwarding direction
Notes
- Environment: OpenSSH port forwardingの構文確認
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.