Remote Port Forwarding Using SSH

This is an explanation of how to forward port $PORT_HOME from host $HOST_HOME to port $PORT_WORK on host $HOST_WORK. In this example SSH will be forwarded. This forwarding must be initiated by host $HOST_WORK as it is not configured to see inbound connections.

These variables can be directly entered into the bash command line:

HOST_HOME = "personal-domain.com"

USER_HOME = "some.home.user"

PORT_HOME = "22"

HOST_WORK = "some-organisation.org"

USER_WORK = "some.work.user"

PORT_WORK = "22"

To initiate the SSH port forwarding from host $HOST_WORK:

ssh $USER_HOME@$HOME -R $PORT_HOME:localhost:$PORT_WORK

When the connection has been established you can test the forwarding from host $HOST_HOME:

ssh $USER_WORK@localhost -p $PORT_HOME

Once you have entered your password you should be connected to host $HOST_WORK.