Skip to content
Advertisement

How to implement seting up ssh tunneling to port… here? [closed]

I am doing my hw on this page: https://www.isi.deterlab.net/file.php?file=/share/shared/Softwareexploitsexercise/index.html#dassign

In the second task, I don’t really know how to do the following:

If you have set up ssh tunneling to port 80 via local port 8118 (a good idea), the memo application can be accessed at http://localhost:8118/cgi-bin/memo.cgi

How to set up ssh tunneling to port 80 via local port 8118? Is that certain command in terminal? Could you tell me how to do? The whole operation should be done in shell because it is on certain platform.

Advertisement

Answer

This ssh feature is called port forwarding.

Local port forwarding listens to the port on local machine and forwards it via the connection to specified destination:

ssh -L 8118:localhost:80 ssh-server

In the example it forwards the port from client machine to localhost of the remote server but you can specify any destination you want. I assume the http server runs on that server.

Remote forwarding does the opposite, i.e. listens on port on remote server and forwards via ssh to specified destination:

ssh -R 8118:localhost:80 ssh-server

Again, it doesn’t have to be localhost. It can forward the port 8118 on ssh-server to any destination accessible from the client machine.

Both forwardings are useful when the service is not directly accessible from the remote destination, either because of firewall, visibility or simply the service running on localhost only.

Advertisement