SSH Tunneling to access localhost on a remote server

Preamble

This document explains how to connect to a service that is listening on a remote server on localhost.

Connecting to remote host

This will connect to the remote host with a tunnel to port 8444. It will hold the terminal open until you interrupt with ctrl+c.

ssh -L 8444:localhost:8444 -N root@remote.host.net

Connecting to remote host and forking to the background

This will connect to the remote host with a tunnel to port 8444. It will fork the ssh process to the background. This is accomplished by adding the -f flag. This will hold the connection open indefinitely until it is killed.

ssh -L 8444:localhost:8444 -N -f root@remote.host.net