Simple remote browsing
If you'd like to browse the web locally as if you were sitting in front of a remote box:
$ ssh -X username@remote.example.com
then run Firefox inside the remote terminal session:
$ firefox https://test-ipv6.com/
Notice the usage of -X
flag in the ssh
command.
You can also do both steps in a single go, like shown below:
$ ssh -X username@remote.example.com firefox http://test-ipv6.com/
Tunnelling a remote IP:port
If you have an application running remotely which exposes some sort of web frontend, you will be interested on exposing the remote IP:port as if it is a local IP:port. In this case, the -L
option defines a correspondence between localhost:localport
and remotehost:remoteport
, as shown in the pseudo command below:
ssh -L localhost:localport:remotehost:remoteport remoteuser@remotehost
For example:
$ ssh -L 127.0.0.1:18080:internal.example.com:8080 username@router.example.com
then run Firefox locally:
$ firefox http://127.0.0.1:18080
In the example above, you are connecting via SSH onto username@router.example.com
, and you are interested on a web frontend exposed at internal.example.com:8080
. This remote IP:port will be exposed locally at 127.0.0.1:18080
.