Create a listener on the SSH server for localhost:9000 and forward it to web.example.test:80, which the client can reach.
Which specification is appropriate?
-R remote_port:destination:destination_port creates a listener on the SSH server side.
Detailed explanation
ssh -L 9000:web.example.test:80 trainee@gateway.example.testIncorrect. -L creates a client-side listener, not a server-side one.
ssh -R 9000:web.example.test:80 trainee@gateway.example.testCorrect. -R creates the remote listener and sends connections to the client-side destination.
ssh -D 9000:web.example.test:80 trainee@gateway.example.testIncorrect. -D is for a SOCKS proxy and does not express this fixed destination.
ssh -p 9000 web.example.test trainee@gateway.example.testIncorrect. -p selects the SSH connection port.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s\n' 'ssh -R 9000:web.example.test:80 trainee@gateway.example.test'Expected result
ssh -R 9000:web.example.test:80 trainee@gateway.example.testKey points
- -R
- Remote-side listener
- Difference from -L
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
Host key
A server identity key used by SSH clients to detect a changed endpoint.
User key
A key pair used to authenticate a user to an SSH server.
Port forwarding
An SSH tunnel that carries traffic between a local, remote, or dynamic endpoint.