You can forward a port on your local machine to another machine and it's also possible to forward a port on a remote machine to another machine. In the following examples, you will get a shell prompt once the forwarding is complete. Keep this shell open to use the port forward and exit it whenever you want to stop the port forward.
- This command will forward port 8000 on your local machine to port 80 on www.kernel.org:
ssh -L 8000:www.kernel.org:80user@localhost
Replace user with the username on your local machine.
- This command will forward port 8000 on a remote machine to port 80 of www.kernel.org:
ssh -L 8000:www.kernel.org:80user@REMOTE_MACHINE
Here, replace REMOTE_MACHINE with the hostname or IP address of the remote machine and user with the username you have SSH access to.