Create an ssh tunnel

On Linux commandline

Create a forward tunnel

ssh <user@remote.host> -L:8080:remote.host:8080

Explanation:

Create a tunnel for port 8080 on the local machine to port 8080 on the remote machine.

Any requests to localhost:8080 will be routed to remote.host:8080

Create a reverse tunnel

ssh <username@remote.host> -R 0.0.0.0:5678:localhost:5678

Explanation:

A reverse tunnel is where the traffic originates from the remote host. When traffic for port 5678 is requested on the remote machine, it is forwarded to the internal, local network, machine.

The -R 0.0.0.0:5678 means the remote machine will accept connections from any interface.

Note: you will need to make some modifications to the /etc/ssh/sshd_config file to make this happen. The default behaviour in Ubuntu is not to accept from a non-localhost address.