1

Consider this scnerio:

apache server listening on 192.168.2.xx. There is no port forwarding setup on router, so this apache instance cannot be accessed from wan.

I have access to same machine over ssh. Router is forwarding port 22 to target machine.

What I want to do is connect a web browser to that apache instance using my ssh connection.

Is this possible?

1

Absolutely. You can use ssh -L to accomplish this type of port forwarding. Presuming your target machine's Apache is listening on 80, do this from your client machine:

ssh -L 6789:localhost:80 target-machine

Will allow you to talk to your target machine's Apache via localhost:6789 on the client. Specifically, you could visit http://localhost:6789 in your web browser.

Commonly, the -N flag is used in conjunction with ssh -L, which will prevent SSH from running any remote commands, and just forward the port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.