Through bastion.example.test, forward local TCP port 8080 to internal.example.test:80.
Run a tunnel only; do not execute a remote command.
Which command is appropriate?
ssh -L LOCAL:DEST_HOST:DEST_PORT listens on the client side and reaches the destination from the SSH server side. -N disables remote command execution.
Detailed explanation
ssh -N -R 8080:internal.example.test:80 bastion.example.testIncorrect. -R creates remote-side listening, not local forwarding.
Incorrect. -R creates remote-side listening, not local forwarding.
ssh -N -D 8080:internal.example.test:80 bastion.example.testIncorrect. -D creates dynamic SOCKS forwarding rather than a fixed destination.
Incorrect. -D creates dynamic SOCKS forwarding rather than a fixed destination.
ssh -N -X 8080:internal.example.test:80 bastion.example.testIncorrect. -X is for X11 forwarding.
Incorrect. -X is for X11 forwarding.
ssh -N -L 8080:internal.example.test:80 bastion.example.testCorrect. It forwards local port 8080 to the internal service.
Correct. It forwards local port 8080 to the internal service.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '-L=local forwarding' '8080=local listen port' 'internal.example.test:80=destination' '-N=no remote command'Expected result
-L=local forwarding
8080=local listen port
internal.example.test:80=destination
-N=no remote commandKey points
- -L listens locally
- Destination is reached from the server side
- -N is tunnel-only
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.